fabric-rails 1.0.12 → 1.0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. data/CHANGELOG.md +16 -0
  2. data/README.md +1 -1
  3. data/lib/fabric/rails/version.rb +2 -2
  4. data/vendor/assets/javascripts/event.js +1909 -0
  5. data/vendor/assets/javascripts/fabric.js +64 -16464
  6. data/vendor/assets/javascripts/fabric/HEADER.js +31 -0
  7. data/vendor/assets/javascripts/fabric/canvas.class.js +1007 -0
  8. data/vendor/assets/javascripts/fabric/canvas_animation.mixin.js +113 -0
  9. data/vendor/assets/javascripts/fabric/canvas_events.mixin.js +482 -0
  10. data/vendor/assets/javascripts/fabric/canvas_gestures.mixin.js +79 -0
  11. data/vendor/assets/javascripts/fabric/canvas_serialization.mixin.js +311 -0
  12. data/vendor/assets/javascripts/fabric/circle.class.js +182 -0
  13. data/vendor/assets/javascripts/fabric/color.class.js +284 -0
  14. data/vendor/assets/javascripts/fabric/ellipse.class.js +169 -0
  15. data/vendor/assets/javascripts/fabric/freedrawing.class.js +256 -0
  16. data/vendor/assets/javascripts/fabric/gradient.class.js +211 -0
  17. data/vendor/assets/javascripts/fabric/group.class.js +556 -0
  18. data/vendor/assets/javascripts/fabric/image.class.js +418 -0
  19. data/vendor/assets/javascripts/fabric/image_filters.js +809 -0
  20. data/vendor/assets/javascripts/fabric/intersection.class.js +178 -0
  21. data/vendor/assets/javascripts/fabric/line.class.js +188 -0
  22. data/vendor/assets/javascripts/fabric/log.js +26 -0
  23. data/vendor/assets/javascripts/fabric/node.js +149 -0
  24. data/vendor/assets/javascripts/fabric/object.class.js +1068 -0
  25. data/vendor/assets/javascripts/fabric/object_geometry.mixin.js +308 -0
  26. data/vendor/assets/javascripts/fabric/object_interactivity.mixin.js +496 -0
  27. data/vendor/assets/javascripts/fabric/object_origin.mixin.js +207 -0
  28. data/vendor/assets/javascripts/fabric/object_straightening.mixin.js +94 -0
  29. data/vendor/assets/javascripts/fabric/observable.mixin.js +91 -0
  30. data/vendor/assets/javascripts/fabric/parser.js +750 -0
  31. data/vendor/assets/javascripts/fabric/path.class.js +794 -0
  32. data/vendor/assets/javascripts/fabric/path_group.class.js +240 -0
  33. data/vendor/assets/javascripts/fabric/pattern.class.js +69 -0
  34. data/vendor/assets/javascripts/fabric/point.class.js +327 -0
  35. data/vendor/assets/javascripts/fabric/polygon.class.js +184 -0
  36. data/vendor/assets/javascripts/fabric/polyline.class.js +157 -0
  37. data/vendor/assets/javascripts/fabric/rect.class.js +298 -0
  38. data/vendor/assets/javascripts/fabric/scout.js +45 -0
  39. data/vendor/assets/javascripts/fabric/shadow.class.js +70 -0
  40. data/vendor/assets/javascripts/fabric/stateful.js +88 -0
  41. data/vendor/assets/javascripts/fabric/static_canvas.class.js +1298 -0
  42. data/vendor/assets/javascripts/fabric/text.class.js +934 -0
  43. data/vendor/assets/javascripts/fabric/triangle.class.js +108 -0
  44. data/vendor/assets/javascripts/fabric/util/anim_ease.js +360 -0
  45. data/vendor/assets/javascripts/fabric/util/dom_event.js +237 -0
  46. data/vendor/assets/javascripts/fabric/util/dom_misc.js +245 -0
  47. data/vendor/assets/javascripts/fabric/util/dom_request.js +72 -0
  48. data/vendor/assets/javascripts/fabric/util/dom_style.js +71 -0
  49. data/vendor/assets/javascripts/fabric/util/lang_array.js +250 -0
  50. data/vendor/assets/javascripts/fabric/util/lang_class.js +97 -0
  51. data/vendor/assets/javascripts/fabric/util/lang_function.js +35 -0
  52. data/vendor/assets/javascripts/fabric/util/lang_object.js +34 -0
  53. data/vendor/assets/javascripts/fabric/util/lang_string.js +60 -0
  54. data/vendor/assets/javascripts/fabric/util/misc.js +406 -0
  55. data/vendor/assets/javascripts/json2.js +491 -0
  56. metadata +53 -2
@@ -0,0 +1,240 @@
1
+ (function(global) {
2
+
3
+ "use strict";
4
+
5
+ var fabric = global.fabric || (global.fabric = { }),
6
+ extend = fabric.util.object.extend,
7
+ invoke = fabric.util.array.invoke,
8
+ parentToObject = fabric.Object.prototype.toObject,
9
+ camelize = fabric.util.string.camelize,
10
+ capitalize = fabric.util.string.capitalize;
11
+
12
+ if (fabric.PathGroup) {
13
+ fabric.warn('fabric.PathGroup is already defined');
14
+ return;
15
+ }
16
+
17
+ /**
18
+ * Path group class
19
+ * @class PathGroup
20
+ * @extends fabric.Path
21
+ */
22
+ fabric.PathGroup = fabric.util.createClass(fabric.Path, /** @scope fabric.PathGroup.prototype */ {
23
+
24
+ /**
25
+ * Type of an object
26
+ * @property
27
+ * @type String
28
+ */
29
+ type: 'path-group',
30
+
31
+ /**
32
+ * Fill value
33
+ * @property
34
+ * @type String
35
+ */
36
+ fill: '',
37
+
38
+ /**
39
+ * Constructor
40
+ * @method initialize
41
+ * @param {Array} paths
42
+ * @param {Object} [options] Options object
43
+ * @return {fabric.PathGroup} thisArg
44
+ */
45
+ initialize: function(paths, options) {
46
+
47
+ options = options || { };
48
+ this.paths = paths || [ ];
49
+
50
+ for (var i = this.paths.length; i--; ) {
51
+ this.paths[i].group = this;
52
+ }
53
+
54
+ this.setOptions(options);
55
+ this.setCoords();
56
+
57
+ if (options.sourcePath) {
58
+ this.setSourcePath(options.sourcePath);
59
+ }
60
+ },
61
+
62
+ /**
63
+ * Renders this group on a specified context
64
+ * @method render
65
+ * @param {CanvasRenderingContext2D} ctx Context to render this instance on
66
+ */
67
+ render: function(ctx) {
68
+ ctx.save();
69
+
70
+ var m = this.transformMatrix;
71
+ if (m) {
72
+ ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
73
+ }
74
+
75
+ this.transform(ctx);
76
+
77
+ this._setShadow(ctx);
78
+ for (var i = 0, l = this.paths.length; i < l; ++i) {
79
+ this.paths[i].render(ctx, true);
80
+ }
81
+ this._removeShadow(ctx);
82
+
83
+ if (this.active) {
84
+ this.drawBorders(ctx);
85
+ this.drawControls(ctx);
86
+ }
87
+ ctx.restore();
88
+ },
89
+
90
+ /**
91
+ * Sets certain property to a certain value
92
+ * @method _set
93
+ * @param {String} prop
94
+ * @param {Any} value
95
+ * @return {fabric.PathGroup} thisArg
96
+ */
97
+ _set: function(prop, value) {
98
+
99
+ if ((prop === 'fill' || prop === 'overlayFill') && value && this.isSameColor()) {
100
+ var i = this.paths.length;
101
+ while (i--) {
102
+ this.paths[i]._set(prop, value);
103
+ }
104
+ }
105
+
106
+ return this.callSuper('_set', prop, value);
107
+ },
108
+
109
+ /**
110
+ * Returns object representation of this path group
111
+ * @method toObject
112
+ * @param {Array} [propertiesToInclude]
113
+ * @return {Object} object representation of an instance
114
+ */
115
+ toObject: function(propertiesToInclude) {
116
+ return extend(parentToObject.call(this, propertiesToInclude), {
117
+ paths: invoke(this.getObjects(), 'toObject', propertiesToInclude),
118
+ sourcePath: this.sourcePath
119
+ });
120
+ },
121
+
122
+ /**
123
+ * Returns dataless object representation of this path group
124
+ * @method toDatalessObject
125
+ * @param {Array} [propertiesToInclude]
126
+ * @return {Object} dataless object representation of an instance
127
+ */
128
+ toDatalessObject: function(propertiesToInclude) {
129
+ var o = this.toObject(propertiesToInclude);
130
+ if (this.sourcePath) {
131
+ o.paths = this.sourcePath;
132
+ }
133
+ return o;
134
+ },
135
+
136
+ /**
137
+ * Returns svg representation of an instance
138
+ * @method toSVG
139
+ * @return {String} svg representation of an instance
140
+ */
141
+ toSVG: function() {
142
+ var objects = this.getObjects();
143
+ var markup = [
144
+ '<g ',
145
+ 'style="', this.getSvgStyles(), '" ',
146
+ 'transform="', this.getSvgTransform(), '" ',
147
+ '>'
148
+ ];
149
+
150
+ for (var i = 0, len = objects.length; i < len; i++) {
151
+ markup.push(objects[i].toSVG());
152
+ }
153
+ markup.push('</g>');
154
+
155
+ return markup.join('');
156
+ },
157
+
158
+ /**
159
+ * Returns a string representation of this path group
160
+ * @method toString
161
+ * @return {String} string representation of an object
162
+ */
163
+ toString: function() {
164
+ return '#<fabric.PathGroup (' + this.complexity() +
165
+ '): { top: ' + this.top + ', left: ' + this.left + ' }>';
166
+ },
167
+
168
+ /**
169
+ * Returns true if all paths in this group are of same color
170
+ * @method isSameColor
171
+ * @return {Boolean} true if all paths are of the same color (`fill`)
172
+ */
173
+ isSameColor: function() {
174
+ var firstPathFill = this.getObjects()[0].get('fill');
175
+ return this.getObjects().every(function(path) {
176
+ return path.get('fill') === firstPathFill;
177
+ });
178
+ },
179
+
180
+ /**
181
+ * Returns number representation of object's complexity
182
+ * @method complexity
183
+ * @return {Number} complexity
184
+ */
185
+ complexity: function() {
186
+ return this.paths.reduce(function(total, path) {
187
+ return total + ((path && path.complexity) ? path.complexity() : 0);
188
+ }, 0);
189
+ },
190
+
191
+ /**
192
+ * Makes path group grayscale
193
+ * @method toGrayscale
194
+ * @return {fabric.PathGroup} thisArg
195
+ */
196
+ toGrayscale: function() {
197
+ var i = this.paths.length;
198
+ while (i--) {
199
+ this.paths[i].toGrayscale();
200
+ }
201
+ return this;
202
+ },
203
+
204
+ /**
205
+ * Returns all paths in this path group
206
+ * @method getObjects
207
+ * @return {Array} array of path objects included in this path group
208
+ */
209
+ getObjects: function() {
210
+ return this.paths;
211
+ }
212
+ });
213
+
214
+ /**
215
+ * @private
216
+ * @method instantiatePaths
217
+ */
218
+ function instantiatePaths(paths) {
219
+ for (var i = 0, len = paths.length; i < len; i++) {
220
+ if (!(paths[i] instanceof fabric.Object)) {
221
+ var klassName = camelize(capitalize(paths[i].type));
222
+ paths[i] = fabric[klassName].fromObject(paths[i]);
223
+ }
224
+ }
225
+ return paths;
226
+ }
227
+
228
+ /**
229
+ * Creates fabric.PathGroup instance from an object representation
230
+ * @static
231
+ * @method fabric.PathGroup.fromObject
232
+ * @param {Object} object
233
+ * @return {fabric.PathGroup}
234
+ */
235
+ fabric.PathGroup.fromObject = function(object) {
236
+ var paths = instantiatePaths(object.paths);
237
+ return new fabric.PathGroup(paths, object);
238
+ };
239
+
240
+ })(typeof exports !== 'undefined' ? exports : this);
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Pattern class
3
+ * @class Pattern
4
+ * @memberOf fabric
5
+ */
6
+ fabric.Pattern = fabric.util.createClass(/** @scope fabric.Pattern.prototype */ {
7
+
8
+ /**
9
+ * Repeat property of a pattern (one of repeat, repeat-x, repeat-y)
10
+ * @property
11
+ * @type String
12
+ */
13
+ repeat: 'repeat',
14
+
15
+ /**
16
+ * Constructor
17
+ * @method initialize
18
+ * @param {Object} [options]
19
+ * @return {fabric.Pattern} thisArg
20
+ */
21
+ initialize: function(options) {
22
+ options || (options = { });
23
+
24
+ if (options.source) {
25
+ this.source = typeof options.source === 'string'
26
+ ? new Function(options.source)
27
+ : options.source;
28
+ }
29
+ if (options.repeat) {
30
+ this.repeat = options.repeat;
31
+ }
32
+ },
33
+
34
+ /**
35
+ * Returns object representation of a pattern
36
+ * @method toObject
37
+ * @return {Object}
38
+ */
39
+ toObject: function() {
40
+
41
+ var source;
42
+
43
+ // callback
44
+ if (typeof this.source === 'function') {
45
+ source = String(this.source)
46
+ .match(/function\s+\w*\s*\(.*\)\s+\{([\s\S]*)\}/)[1];
47
+ }
48
+ // <img> element
49
+ else if (typeof this.source.src === 'string') {
50
+ source = this.source.src;
51
+ }
52
+
53
+ return {
54
+ source: source,
55
+ repeat: this.repeat
56
+ };
57
+ },
58
+
59
+ /**
60
+ * Returns an instance of CanvasPattern
61
+ * @method toLive
62
+ * @param ctx
63
+ * @return {CanvasPattern}
64
+ */
65
+ toLive: function(ctx) {
66
+ var source = typeof this.source === 'function' ? this.source() : this.source;
67
+ return ctx.createPattern(source, this.repeat);
68
+ }
69
+ });
@@ -0,0 +1,327 @@
1
+ (function(global) {
2
+
3
+ "use strict";
4
+
5
+ /* Adaptation of work of Kevin Lindsey (kevin@kevlindev.com) */
6
+
7
+ var fabric = global.fabric || (global.fabric = { });
8
+
9
+ if (fabric.Point) {
10
+ fabric.warn('fabric.Point is already defined');
11
+ return;
12
+ }
13
+
14
+ fabric.Point = Point;
15
+
16
+ /**
17
+ * Point class
18
+ * @name Point
19
+ * @memberOf fabric
20
+ * @constructor
21
+ * @param {Number} x
22
+ * @param {Number} y
23
+ * @return {fabric.Point} thisArg
24
+ */
25
+ function Point(x, y) {
26
+ if (arguments.length > 0) {
27
+ this.init(x, y);
28
+ }
29
+ }
30
+
31
+ Point.prototype = /** @scope fabric.Point.prototype */ {
32
+
33
+ constructor: Point,
34
+
35
+ /**
36
+ * Constructor
37
+ * @method init
38
+ * @param {Number} x left offset
39
+ * @param {Number} y top offset
40
+ */
41
+ init: function (x, y) {
42
+ this.x = x;
43
+ this.y = y;
44
+ },
45
+
46
+ /**
47
+ * Adds another point to this one and returns another one
48
+ * @method add
49
+ * @param {fabric.Point} that
50
+ * @return {fabric.Point} new Point instance with added values
51
+ */
52
+ add: function (that) {
53
+ return new Point(this.x + that.x, this.y + that.y);
54
+ },
55
+
56
+ /**
57
+ * Adds another point to this one
58
+ * @method addEquals
59
+ * @param {fabric.Point} that
60
+ * @return {fabric.Point} thisArg
61
+ */
62
+ addEquals: function (that) {
63
+ this.x += that.x;
64
+ this.y += that.y;
65
+ return this;
66
+ },
67
+
68
+ /**
69
+ * Adds value to this point and returns a new one
70
+ * @method scalarAdd
71
+ * @param {Number} scalar
72
+ * @return {fabric.Point} new Point with added value
73
+ */
74
+ scalarAdd: function (scalar) {
75
+ return new Point(this.x + scalar, this.y + scalar);
76
+ },
77
+
78
+ /**
79
+ * Adds value to this point
80
+ * @method scalarAddEquals
81
+ * @param {Number} scalar
82
+ * @param {fabric.Point} thisArg
83
+ */
84
+ scalarAddEquals: function (scalar) {
85
+ this.x += scalar;
86
+ this.y += scalar;
87
+ return this;
88
+ },
89
+
90
+ /**
91
+ * Subtracts another point from this point and returns a new one
92
+ * @method subtract
93
+ * @param {fabric.Point} that
94
+ * @return {fabric.Point} new Point object with subtracted values
95
+ */
96
+ subtract: function (that) {
97
+ return new Point(this.x - that.x, this.y - that.y);
98
+ },
99
+
100
+ /**
101
+ * Subtracts another point from this point
102
+ * @method subtractEquals
103
+ * @param {fabric.Point} that
104
+ * @return {fabric.Point} thisArg
105
+ */
106
+ subtractEquals: function (that) {
107
+ this.x -= that.x;
108
+ this.y -= that.y;
109
+ return this;
110
+ },
111
+
112
+ /**
113
+ * Subtracts value from this point and returns a new one
114
+ * @method scalarSubtract
115
+ * @param {Number} scalar
116
+ * @return {fabric.Point}
117
+ */
118
+ scalarSubtract: function (scalar) {
119
+ return new Point(this.x - scalar, this.y - scalar);
120
+ },
121
+
122
+ /**
123
+ * Subtracts value from this point
124
+ * @method scalarSubtractEquals
125
+ * @param {Number} scalar
126
+ * @return {fabric.Point} thisArg
127
+ */
128
+ scalarSubtractEquals: function (scalar) {
129
+ this.x -= scalar;
130
+ this.y -= scalar;
131
+ return this;
132
+ },
133
+
134
+ /**
135
+ * Miltiplies this point by a value and returns a new one
136
+ * @method multiply
137
+ * @param {Number} scalar
138
+ * @return {fabric.Point}
139
+ */
140
+ multiply: function (scalar) {
141
+ return new Point(this.x * scalar, this.y * scalar);
142
+ },
143
+
144
+ /**
145
+ * Miltiplies this point by a value
146
+ * @method multiplyEquals
147
+ * @param {Number} scalar
148
+ * @return {fabric.Point} thisArg
149
+ */
150
+ multiplyEquals: function (scalar) {
151
+ this.x *= scalar;
152
+ this.y *= scalar;
153
+ return this;
154
+ },
155
+
156
+ /**
157
+ * Divides this point by a value and returns a new one
158
+ * @method divide
159
+ * @param {Number} scalar
160
+ * @return {fabric.Point}
161
+ */
162
+ divide: function (scalar) {
163
+ return new Point(this.x / scalar, this.y / scalar);
164
+ },
165
+
166
+ /**
167
+ * Divides this point by a value
168
+ * @method divideEquals
169
+ * @param {Number} scalar
170
+ * @return {fabric.Point} thisArg
171
+ */
172
+ divideEquals: function (scalar) {
173
+ this.x /= scalar;
174
+ this.y /= scalar;
175
+ return this;
176
+ },
177
+
178
+ /**
179
+ * Returns true if this point is equal to another one
180
+ * @method eq
181
+ * @param {fabric.Point} that
182
+ * @return {Boolean}
183
+ */
184
+ eq: function (that) {
185
+ return (this.x === that.x && this.y === that.y);
186
+ },
187
+
188
+ /**
189
+ * Returns true if this point is less than another one
190
+ * @method lt
191
+ * @param {fabric.Point} that
192
+ * @return {Boolean}
193
+ */
194
+ lt: function (that) {
195
+ return (this.x < that.x && this.y < that.y);
196
+ },
197
+
198
+ /**
199
+ * Returns true if this point is less than or equal to another one
200
+ * @method lte
201
+ * @param {fabric.Point} that
202
+ * @return {Boolean}
203
+ */
204
+ lte: function (that) {
205
+ return (this.x <= that.x && this.y <= that.y);
206
+ },
207
+
208
+ /**
209
+
210
+ * Returns true if this point is greater another one
211
+ * @method gt
212
+ * @param {fabric.Point} that
213
+ * @return {Boolean}
214
+ */
215
+ gt: function (that) {
216
+ return (this.x > that.x && this.y > that.y);
217
+ },
218
+
219
+ /**
220
+ * Returns true if this point is greater than or equal to another one
221
+ * @method gte
222
+ * @param {fabric.Point} that
223
+ * @return {Boolean}
224
+ */
225
+ gte: function (that) {
226
+ return (this.x >= that.x && this.y >= that.y);
227
+ },
228
+
229
+ /**
230
+ * Returns new point which is the result of linear interpolation with this one and another one
231
+ * @method lerp
232
+ * @param {fabric.Point} that
233
+ * @param {Number} t
234
+ * @return {fabric.Point}
235
+ */
236
+ lerp: function (that, t) {
237
+ return new Point(this.x + (that.x - this.x) * t, this.y + (that.y - this.y) * t);
238
+ },
239
+
240
+ /**
241
+ * Returns distance from this point and another one
242
+ * @method distanceFrom
243
+ * @param {fabric.Point} that
244
+ * @return {Number}
245
+ */
246
+ distanceFrom: function (that) {
247
+ var dx = this.x - that.x,
248
+ dy = this.y - that.y;
249
+ return Math.sqrt(dx * dx + dy * dy);
250
+ },
251
+
252
+ /**
253
+ * Returns the point between this point and another one
254
+ * @method midPointFrom
255
+ * @param {fabric.Point} that
256
+ * @return {fabric.Point}
257
+ */
258
+ midPointFrom: function (that) {
259
+ return new Point(this.x + (that.x - this.x)/2, this.y + (that.y - this.y)/2);
260
+ },
261
+
262
+ /**
263
+ * Returns a new point which is the min of this and another one
264
+ * @method min
265
+ * @param {fabric.Point} that
266
+ * @return {fabric.Point}
267
+ */
268
+ min: function (that) {
269
+ return new Point(Math.min(this.x, that.x), Math.min(this.y, that.y));
270
+ },
271
+
272
+ /**
273
+ * Returns a new point which is the max of this and another one
274
+ * @method max
275
+ * @param {fabric.Point} that
276
+ * @return {fabric.Point}
277
+ */
278
+ max: function (that) {
279
+ return new Point(Math.max(this.x, that.x), Math.max(this.y, that.y));
280
+ },
281
+
282
+ /**
283
+ * Returns string representation of this point
284
+ * @method toString
285
+ * @return {String}
286
+ */
287
+ toString: function () {
288
+ return this.x + "," + this.y;
289
+ },
290
+
291
+ /**
292
+ * Sets x/y of this point
293
+ * @method setXY
294
+ * @param {Number} x
295
+ * @return {Number} y
296
+ */
297
+ setXY: function (x, y) {
298
+ this.x = x;
299
+ this.y = y;
300
+ },
301
+
302
+ /**
303
+ * Sets x/y of this point from another point
304
+ * @method setFromPoint
305
+ * @param {fabric.Point} that
306
+ */
307
+ setFromPoint: function (that) {
308
+ this.x = that.x;
309
+ this.y = that.y;
310
+ },
311
+
312
+ /**
313
+ * Swaps x/y of this point and another point
314
+ * @method setFromPoint
315
+ * @param {fabric.Point} that
316
+ */
317
+ swap: function (that) {
318
+ var x = this.x,
319
+ y = this.y;
320
+ this.x = that.x;
321
+ this.y = that.y;
322
+ that.x = x;
323
+ that.y = y;
324
+ }
325
+ };
326
+
327
+ })(typeof exports !== 'undefined' ? exports : this);