fabric-rails 1.0.12.1 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/fabric/rails/version.rb +2 -2
- data/vendor/assets/javascripts/cufon.js +1226 -0
- data/vendor/assets/javascripts/event.js +20 -20
- data/vendor/assets/javascripts/excanvas.js +1464 -0
- data/vendor/assets/javascripts/fabric.js +56 -33
- data/vendor/assets/javascripts/fabric/HEADER.js +2 -4
- data/vendor/assets/javascripts/fabric/brushes/base_brush.class.js +96 -0
- data/vendor/assets/javascripts/fabric/brushes/circle_brush.class.js +99 -0
- data/vendor/assets/javascripts/fabric/brushes/pattern_brush.class.js +55 -0
- data/vendor/assets/javascripts/fabric/{freedrawing.class.js → brushes/pencil_brush.class.js} +73 -65
- data/vendor/assets/javascripts/fabric/brushes/spray_brush.class.js +157 -0
- data/vendor/assets/javascripts/fabric/canvas.class.js +154 -135
- data/vendor/assets/javascripts/fabric/color.class.js +195 -29
- data/vendor/assets/javascripts/fabric/filters/brightness_filter.class.js +70 -0
- data/vendor/assets/javascripts/fabric/filters/convolute_filter.class.js +122 -0
- data/vendor/assets/javascripts/fabric/filters/gradienttransparency_filter.class.js +69 -0
- data/vendor/assets/javascripts/fabric/filters/grayscale_filter.class.js +61 -0
- data/vendor/assets/javascripts/fabric/filters/invert_filter.class.js +57 -0
- data/vendor/assets/javascripts/fabric/filters/noise_filter.class.js +73 -0
- data/vendor/assets/javascripts/fabric/filters/pixelate_filter.class.js +98 -0
- data/vendor/assets/javascripts/fabric/filters/removewhite_filter.class.js +86 -0
- data/vendor/assets/javascripts/fabric/filters/sepia2_filter.class.js +61 -0
- data/vendor/assets/javascripts/fabric/filters/sepia_filter.class.js +58 -0
- data/vendor/assets/javascripts/fabric/filters/tint_filter.class.js +80 -0
- data/vendor/assets/javascripts/fabric/gradient.class.js +232 -80
- data/vendor/assets/javascripts/fabric/intersection.class.js +10 -28
- data/vendor/assets/javascripts/fabric/log.js +0 -2
- data/vendor/assets/javascripts/fabric/{canvas_animation.mixin.js → mixins/canvas_animation.mixin.js} +3 -6
- data/vendor/assets/javascripts/fabric/mixins/canvas_dataurl_exporter.mixin.js +137 -0
- data/vendor/assets/javascripts/fabric/{canvas_events.mixin.js → mixins/canvas_events.mixin.js} +97 -144
- data/vendor/assets/javascripts/fabric/{canvas_gestures.mixin.js → mixins/canvas_gestures.mixin.js} +4 -8
- data/vendor/assets/javascripts/fabric/{canvas_serialization.mixin.js → mixins/canvas_serialization.mixin.js} +19 -14
- data/vendor/assets/javascripts/fabric/mixins/collection.mixin.js +137 -0
- data/vendor/assets/javascripts/fabric/{object_geometry.mixin.js → mixins/object_geometry.mixin.js} +130 -47
- data/vendor/assets/javascripts/fabric/{object_interactivity.mixin.js → mixins/object_interactivity.mixin.js} +21 -102
- data/vendor/assets/javascripts/fabric/{object_origin.mixin.js → mixins/object_origin.mixin.js} +36 -26
- data/vendor/assets/javascripts/fabric/{object_straightening.mixin.js → mixins/object_straightening.mixin.js} +4 -9
- data/vendor/assets/javascripts/fabric/{observable.mixin.js → mixins/observable.mixin.js} +27 -35
- data/vendor/assets/javascripts/fabric/mixins/stateful.mixin.js +45 -0
- data/vendor/assets/javascripts/fabric/node.js +62 -26
- data/vendor/assets/javascripts/fabric/parser.js +181 -58
- data/vendor/assets/javascripts/fabric/pattern.class.js +43 -14
- data/vendor/assets/javascripts/fabric/point.class.js +4 -43
- data/vendor/assets/javascripts/fabric/shadow.class.js +19 -19
- data/vendor/assets/javascripts/fabric/{circle.class.js → shapes/circle.class.js} +32 -29
- data/vendor/assets/javascripts/fabric/{ellipse.class.js → shapes/ellipse.class.js} +45 -27
- data/vendor/assets/javascripts/fabric/{group.class.js → shapes/group.class.js} +67 -169
- data/vendor/assets/javascripts/fabric/{image.class.js → shapes/image.class.js} +134 -72
- data/vendor/assets/javascripts/fabric/{line.class.js → shapes/line.class.js} +67 -36
- data/vendor/assets/javascripts/fabric/{object.class.js → shapes/object.class.js} +394 -252
- data/vendor/assets/javascripts/fabric/{path.class.js → shapes/path.class.js} +89 -174
- data/vendor/assets/javascripts/fabric/{path_group.class.js → shapes/path_group.class.js} +12 -18
- data/vendor/assets/javascripts/fabric/{polygon.class.js → shapes/polygon.class.js} +64 -38
- data/vendor/assets/javascripts/fabric/{polyline.class.js → shapes/polyline.class.js} +64 -39
- data/vendor/assets/javascripts/fabric/{rect.class.js → shapes/rect.class.js} +78 -112
- data/vendor/assets/javascripts/fabric/{text.class.js → shapes/text.class.js} +264 -270
- data/vendor/assets/javascripts/fabric/shapes/text.cufon.js +79 -0
- data/vendor/assets/javascripts/fabric/{triangle.class.js → shapes/triangle.class.js} +46 -26
- data/vendor/assets/javascripts/fabric/static_canvas.class.js +134 -358
- data/vendor/assets/javascripts/fabric/util/anim_ease.js +2 -31
- data/vendor/assets/javascripts/fabric/util/dom_event.js +21 -7
- data/vendor/assets/javascripts/fabric/util/dom_misc.js +49 -39
- data/vendor/assets/javascripts/fabric/util/dom_request.js +1 -2
- data/vendor/assets/javascripts/fabric/util/dom_style.js +1 -2
- data/vendor/assets/javascripts/fabric/util/lang_array.js +19 -13
- data/vendor/assets/javascripts/fabric/util/lang_class.js +1 -2
- data/vendor/assets/javascripts/fabric/util/lang_function.js +3 -1
- data/vendor/assets/javascripts/fabric/util/lang_object.js +5 -5
- data/vendor/assets/javascripts/fabric/util/lang_string.js +7 -5
- data/vendor/assets/javascripts/fabric/util/misc.js +207 -42
- metadata +47 -29
- data/vendor/assets/javascripts/fabric/image_filters.js +0 -809
- data/vendor/assets/javascripts/fabric/scout.js +0 -45
- data/vendor/assets/javascripts/fabric/stateful.js +0 -88
@@ -1,20 +1,29 @@
|
|
1
1
|
/**
|
2
2
|
* Pattern class
|
3
|
-
* @class Pattern
|
4
|
-
* @memberOf fabric
|
3
|
+
* @class fabric.Pattern
|
5
4
|
*/
|
6
|
-
fabric.Pattern = fabric.util.createClass(/** @
|
5
|
+
fabric.Pattern = fabric.util.createClass(/** @lends fabric.Pattern.prototype */ {
|
7
6
|
|
8
7
|
/**
|
9
8
|
* Repeat property of a pattern (one of repeat, repeat-x, repeat-y)
|
10
|
-
* @property
|
11
9
|
* @type String
|
12
10
|
*/
|
13
11
|
repeat: 'repeat',
|
14
12
|
|
13
|
+
/**
|
14
|
+
* Pattern horizontal offset from object's left/top corner
|
15
|
+
* @type Number
|
16
|
+
*/
|
17
|
+
offsetX: 0,
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Pattern vertical offset from object's left/top corner
|
21
|
+
* @type Number
|
22
|
+
*/
|
23
|
+
offsetY: 0,
|
24
|
+
|
15
25
|
/**
|
16
26
|
* Constructor
|
17
|
-
* @method initialize
|
18
27
|
* @param {Object} [options]
|
19
28
|
* @return {fabric.Pattern} thisArg
|
20
29
|
*/
|
@@ -22,18 +31,38 @@ fabric.Pattern = fabric.util.createClass(/** @scope fabric.Pattern.prototype */
|
|
22
31
|
options || (options = { });
|
23
32
|
|
24
33
|
if (options.source) {
|
25
|
-
|
26
|
-
|
27
|
-
|
34
|
+
if (typeof options.source === 'string') {
|
35
|
+
// function string
|
36
|
+
if (typeof fabric.util.getFunctionBody(options.source) !== 'undefined') {
|
37
|
+
this.source = new Function(fabric.util.getFunctionBody(options.source));
|
38
|
+
}
|
39
|
+
else {
|
40
|
+
// img src string
|
41
|
+
var _this = this;
|
42
|
+
this.source = fabric.util.createImage();
|
43
|
+
fabric.util.loadImage(options.source, function(img) {
|
44
|
+
_this.source = img;
|
45
|
+
});
|
46
|
+
}
|
47
|
+
}
|
48
|
+
else {
|
49
|
+
// img element
|
50
|
+
this.source = options.source;
|
51
|
+
}
|
28
52
|
}
|
29
53
|
if (options.repeat) {
|
30
54
|
this.repeat = options.repeat;
|
31
55
|
}
|
56
|
+
if (options.offsetX) {
|
57
|
+
this.offsetX = options.offsetX;
|
58
|
+
}
|
59
|
+
if (options.offsetY) {
|
60
|
+
this.offsetY = options.offsetY;
|
61
|
+
}
|
32
62
|
},
|
33
63
|
|
34
64
|
/**
|
35
65
|
* Returns object representation of a pattern
|
36
|
-
* @method toObject
|
37
66
|
* @return {Object}
|
38
67
|
*/
|
39
68
|
toObject: function() {
|
@@ -42,8 +71,7 @@ fabric.Pattern = fabric.util.createClass(/** @scope fabric.Pattern.prototype */
|
|
42
71
|
|
43
72
|
// callback
|
44
73
|
if (typeof this.source === 'function') {
|
45
|
-
source = String(this.source)
|
46
|
-
.match(/function\s+\w*\s*\(.*\)\s+\{([\s\S]*)\}/)[1];
|
74
|
+
source = String(this.source);
|
47
75
|
}
|
48
76
|
// <img> element
|
49
77
|
else if (typeof this.source.src === 'string') {
|
@@ -52,13 +80,14 @@ fabric.Pattern = fabric.util.createClass(/** @scope fabric.Pattern.prototype */
|
|
52
80
|
|
53
81
|
return {
|
54
82
|
source: source,
|
55
|
-
repeat: this.repeat
|
83
|
+
repeat: this.repeat,
|
84
|
+
offsetX: this.offsetX,
|
85
|
+
offsetY: this.offsetY
|
56
86
|
};
|
57
87
|
},
|
58
88
|
|
59
89
|
/**
|
60
90
|
* Returns an instance of CanvasPattern
|
61
|
-
* @method toLive
|
62
91
|
* @param ctx
|
63
92
|
* @return {CanvasPattern}
|
64
93
|
*/
|
@@ -66,4 +95,4 @@ fabric.Pattern = fabric.util.createClass(/** @scope fabric.Pattern.prototype */
|
|
66
95
|
var source = typeof this.source === 'function' ? this.source() : this.source;
|
67
96
|
return ctx.createPattern(source, this.repeat);
|
68
97
|
}
|
69
|
-
});
|
98
|
+
});
|
@@ -15,37 +15,23 @@
|
|
15
15
|
|
16
16
|
/**
|
17
17
|
* Point class
|
18
|
-
* @
|
19
|
-
* @memberOf fabric
|
18
|
+
* @class fabric.Point
|
20
19
|
* @constructor
|
21
20
|
* @param {Number} x
|
22
21
|
* @param {Number} y
|
23
22
|
* @return {fabric.Point} thisArg
|
24
23
|
*/
|
25
24
|
function Point(x, y) {
|
26
|
-
|
27
|
-
|
28
|
-
}
|
25
|
+
this.x = x;
|
26
|
+
this.y = y;
|
29
27
|
}
|
30
28
|
|
31
|
-
Point.prototype = /** @
|
29
|
+
Point.prototype = /** @lends fabric.Point.prototype */ {
|
32
30
|
|
33
31
|
constructor: Point,
|
34
32
|
|
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
33
|
/**
|
47
34
|
* Adds another point to this one and returns another one
|
48
|
-
* @method add
|
49
35
|
* @param {fabric.Point} that
|
50
36
|
* @return {fabric.Point} new Point instance with added values
|
51
37
|
*/
|
@@ -55,7 +41,6 @@
|
|
55
41
|
|
56
42
|
/**
|
57
43
|
* Adds another point to this one
|
58
|
-
* @method addEquals
|
59
44
|
* @param {fabric.Point} that
|
60
45
|
* @return {fabric.Point} thisArg
|
61
46
|
*/
|
@@ -67,7 +52,6 @@
|
|
67
52
|
|
68
53
|
/**
|
69
54
|
* Adds value to this point and returns a new one
|
70
|
-
* @method scalarAdd
|
71
55
|
* @param {Number} scalar
|
72
56
|
* @return {fabric.Point} new Point with added value
|
73
57
|
*/
|
@@ -77,7 +61,6 @@
|
|
77
61
|
|
78
62
|
/**
|
79
63
|
* Adds value to this point
|
80
|
-
* @method scalarAddEquals
|
81
64
|
* @param {Number} scalar
|
82
65
|
* @param {fabric.Point} thisArg
|
83
66
|
*/
|
@@ -89,7 +72,6 @@
|
|
89
72
|
|
90
73
|
/**
|
91
74
|
* Subtracts another point from this point and returns a new one
|
92
|
-
* @method subtract
|
93
75
|
* @param {fabric.Point} that
|
94
76
|
* @return {fabric.Point} new Point object with subtracted values
|
95
77
|
*/
|
@@ -99,7 +81,6 @@
|
|
99
81
|
|
100
82
|
/**
|
101
83
|
* Subtracts another point from this point
|
102
|
-
* @method subtractEquals
|
103
84
|
* @param {fabric.Point} that
|
104
85
|
* @return {fabric.Point} thisArg
|
105
86
|
*/
|
@@ -111,7 +92,6 @@
|
|
111
92
|
|
112
93
|
/**
|
113
94
|
* Subtracts value from this point and returns a new one
|
114
|
-
* @method scalarSubtract
|
115
95
|
* @param {Number} scalar
|
116
96
|
* @return {fabric.Point}
|
117
97
|
*/
|
@@ -121,7 +101,6 @@
|
|
121
101
|
|
122
102
|
/**
|
123
103
|
* Subtracts value from this point
|
124
|
-
* @method scalarSubtractEquals
|
125
104
|
* @param {Number} scalar
|
126
105
|
* @return {fabric.Point} thisArg
|
127
106
|
*/
|
@@ -133,7 +112,6 @@
|
|
133
112
|
|
134
113
|
/**
|
135
114
|
* Miltiplies this point by a value and returns a new one
|
136
|
-
* @method multiply
|
137
115
|
* @param {Number} scalar
|
138
116
|
* @return {fabric.Point}
|
139
117
|
*/
|
@@ -143,7 +121,6 @@
|
|
143
121
|
|
144
122
|
/**
|
145
123
|
* Miltiplies this point by a value
|
146
|
-
* @method multiplyEquals
|
147
124
|
* @param {Number} scalar
|
148
125
|
* @return {fabric.Point} thisArg
|
149
126
|
*/
|
@@ -155,7 +132,6 @@
|
|
155
132
|
|
156
133
|
/**
|
157
134
|
* Divides this point by a value and returns a new one
|
158
|
-
* @method divide
|
159
135
|
* @param {Number} scalar
|
160
136
|
* @return {fabric.Point}
|
161
137
|
*/
|
@@ -165,7 +141,6 @@
|
|
165
141
|
|
166
142
|
/**
|
167
143
|
* Divides this point by a value
|
168
|
-
* @method divideEquals
|
169
144
|
* @param {Number} scalar
|
170
145
|
* @return {fabric.Point} thisArg
|
171
146
|
*/
|
@@ -177,7 +152,6 @@
|
|
177
152
|
|
178
153
|
/**
|
179
154
|
* Returns true if this point is equal to another one
|
180
|
-
* @method eq
|
181
155
|
* @param {fabric.Point} that
|
182
156
|
* @return {Boolean}
|
183
157
|
*/
|
@@ -187,7 +161,6 @@
|
|
187
161
|
|
188
162
|
/**
|
189
163
|
* Returns true if this point is less than another one
|
190
|
-
* @method lt
|
191
164
|
* @param {fabric.Point} that
|
192
165
|
* @return {Boolean}
|
193
166
|
*/
|
@@ -197,7 +170,6 @@
|
|
197
170
|
|
198
171
|
/**
|
199
172
|
* Returns true if this point is less than or equal to another one
|
200
|
-
* @method lte
|
201
173
|
* @param {fabric.Point} that
|
202
174
|
* @return {Boolean}
|
203
175
|
*/
|
@@ -208,7 +180,6 @@
|
|
208
180
|
/**
|
209
181
|
|
210
182
|
* Returns true if this point is greater another one
|
211
|
-
* @method gt
|
212
183
|
* @param {fabric.Point} that
|
213
184
|
* @return {Boolean}
|
214
185
|
*/
|
@@ -218,7 +189,6 @@
|
|
218
189
|
|
219
190
|
/**
|
220
191
|
* Returns true if this point is greater than or equal to another one
|
221
|
-
* @method gte
|
222
192
|
* @param {fabric.Point} that
|
223
193
|
* @return {Boolean}
|
224
194
|
*/
|
@@ -228,7 +198,6 @@
|
|
228
198
|
|
229
199
|
/**
|
230
200
|
* Returns new point which is the result of linear interpolation with this one and another one
|
231
|
-
* @method lerp
|
232
201
|
* @param {fabric.Point} that
|
233
202
|
* @param {Number} t
|
234
203
|
* @return {fabric.Point}
|
@@ -239,7 +208,6 @@
|
|
239
208
|
|
240
209
|
/**
|
241
210
|
* Returns distance from this point and another one
|
242
|
-
* @method distanceFrom
|
243
211
|
* @param {fabric.Point} that
|
244
212
|
* @return {Number}
|
245
213
|
*/
|
@@ -251,7 +219,6 @@
|
|
251
219
|
|
252
220
|
/**
|
253
221
|
* Returns the point between this point and another one
|
254
|
-
* @method midPointFrom
|
255
222
|
* @param {fabric.Point} that
|
256
223
|
* @return {fabric.Point}
|
257
224
|
*/
|
@@ -261,7 +228,6 @@
|
|
261
228
|
|
262
229
|
/**
|
263
230
|
* Returns a new point which is the min of this and another one
|
264
|
-
* @method min
|
265
231
|
* @param {fabric.Point} that
|
266
232
|
* @return {fabric.Point}
|
267
233
|
*/
|
@@ -271,7 +237,6 @@
|
|
271
237
|
|
272
238
|
/**
|
273
239
|
* Returns a new point which is the max of this and another one
|
274
|
-
* @method max
|
275
240
|
* @param {fabric.Point} that
|
276
241
|
* @return {fabric.Point}
|
277
242
|
*/
|
@@ -281,7 +246,6 @@
|
|
281
246
|
|
282
247
|
/**
|
283
248
|
* Returns string representation of this point
|
284
|
-
* @method toString
|
285
249
|
* @return {String}
|
286
250
|
*/
|
287
251
|
toString: function () {
|
@@ -290,7 +254,6 @@
|
|
290
254
|
|
291
255
|
/**
|
292
256
|
* Sets x/y of this point
|
293
|
-
* @method setXY
|
294
257
|
* @param {Number} x
|
295
258
|
* @return {Number} y
|
296
259
|
*/
|
@@ -301,7 +264,6 @@
|
|
301
264
|
|
302
265
|
/**
|
303
266
|
* Sets x/y of this point from another point
|
304
|
-
* @method setFromPoint
|
305
267
|
* @param {fabric.Point} that
|
306
268
|
*/
|
307
269
|
setFromPoint: function (that) {
|
@@ -311,7 +273,6 @@
|
|
311
273
|
|
312
274
|
/**
|
313
275
|
* Swaps x/y of this point and another point
|
314
|
-
* @method setFromPoint
|
315
276
|
* @param {fabric.Point} that
|
316
277
|
*/
|
317
278
|
swap: function (that) {
|
@@ -1,41 +1,41 @@
|
|
1
1
|
/**
|
2
2
|
* Shadow class
|
3
|
-
* @class Shadow
|
4
|
-
* @memberOf fabric
|
3
|
+
* @class fabric.Shadow
|
5
4
|
*/
|
6
|
-
fabric.Shadow = fabric.util.createClass(/** @
|
5
|
+
fabric.Shadow = fabric.util.createClass(/** @lends fabric.Shadow.prototype */ {
|
7
6
|
|
8
7
|
/**
|
9
8
|
* Shadow color
|
10
|
-
* @property
|
11
9
|
* @type String
|
12
10
|
*/
|
13
11
|
color: 'rgb(0,0,0)',
|
14
12
|
|
15
13
|
/**
|
16
14
|
* Shadow blur
|
17
|
-
* @property
|
18
15
|
* @type Number
|
19
16
|
*/
|
20
17
|
blur: 0,
|
21
18
|
|
22
19
|
/**
|
23
20
|
* Shadow horizontal offset
|
24
|
-
* @property
|
25
21
|
* @type Number
|
26
22
|
*/
|
27
23
|
offsetX: 0,
|
28
24
|
|
29
25
|
/**
|
30
26
|
* Shadow vertical offset
|
31
|
-
* @property
|
32
27
|
* @type Number
|
33
28
|
*/
|
34
29
|
offsetY: 0,
|
35
30
|
|
31
|
+
/**
|
32
|
+
* Whether the shadow should affect stroke operations
|
33
|
+
* @type Boolean
|
34
|
+
*/
|
35
|
+
affectStroke: false,
|
36
|
+
|
36
37
|
/**
|
37
38
|
* Constructor
|
38
|
-
* @method initialize
|
39
39
|
* @param [options] Options object with any of color, blur, offsetX, offsetX properties
|
40
40
|
* @return {fabric.Shadow} thisArg
|
41
41
|
*/
|
@@ -45,9 +45,18 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ {
|
|
45
45
|
}
|
46
46
|
},
|
47
47
|
|
48
|
+
/* _TO_SVG_START_ */
|
49
|
+
/**
|
50
|
+
* Returns SVG representation of a shadow
|
51
|
+
* @return {String}
|
52
|
+
*/
|
53
|
+
toSVG: function() {
|
54
|
+
|
55
|
+
},
|
56
|
+
/* _TO_SVG_END_ */
|
57
|
+
|
48
58
|
/**
|
49
59
|
* Returns object representation of a shadow
|
50
|
-
* @method toObject
|
51
60
|
* @return {Object}
|
52
61
|
*/
|
53
62
|
toObject: function() {
|
@@ -57,14 +66,5 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ {
|
|
57
66
|
offsetX: this.offsetX,
|
58
67
|
offsetY: this.offsetY
|
59
68
|
};
|
60
|
-
},
|
61
|
-
|
62
|
-
/**
|
63
|
-
* Returns SVG representation of a shadow
|
64
|
-
* @method toSVG
|
65
|
-
* @return {String}
|
66
|
-
*/
|
67
|
-
toSVG: function() {
|
68
|
-
|
69
69
|
}
|
70
|
-
});
|
70
|
+
});
|
@@ -13,21 +13,20 @@
|
|
13
13
|
|
14
14
|
/**
|
15
15
|
* Circle class
|
16
|
-
* @class Circle
|
16
|
+
* @class fabric.Circle
|
17
17
|
* @extends fabric.Object
|
18
18
|
*/
|
19
|
-
fabric.Circle = fabric.util.createClass(fabric.Object, /** @
|
19
|
+
fabric.Circle = fabric.util.createClass(fabric.Object, /** @lends fabric.Circle.prototype */ {
|
20
20
|
|
21
21
|
/**
|
22
22
|
* Type of an object
|
23
|
-
* @property
|
24
23
|
* @type String
|
24
|
+
* @default
|
25
25
|
*/
|
26
26
|
type: 'circle',
|
27
27
|
|
28
28
|
/**
|
29
29
|
* Constructor
|
30
|
-
* @method initialize
|
31
30
|
* @param {Object} [options] Options object
|
32
31
|
* @return {fabric.Circle} thisArg
|
33
32
|
*/
|
@@ -43,7 +42,6 @@
|
|
43
42
|
|
44
43
|
/**
|
45
44
|
* Returns object representation of an instance
|
46
|
-
* @method toObject
|
47
45
|
* @param {Array} propertiesToInclude
|
48
46
|
* @return {Object} object representation of an instance
|
49
47
|
*/
|
@@ -53,23 +51,36 @@
|
|
53
51
|
});
|
54
52
|
},
|
55
53
|
|
54
|
+
/* _TO_SVG_START_ */
|
56
55
|
/**
|
57
56
|
* Returns svg representation of an instance
|
58
|
-
* @method toSVG
|
59
57
|
* @return {String} svg representation of an instance
|
60
58
|
*/
|
61
59
|
toSVG: function() {
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
60
|
+
var markup = [];
|
61
|
+
|
62
|
+
if (this.fill && this.fill.toLive) {
|
63
|
+
markup.push(this.fill.toSVG(this, false));
|
64
|
+
}
|
65
|
+
if (this.stroke && this.stroke.toLive) {
|
66
|
+
markup.push(this.stroke.toSVG(this, false));
|
67
|
+
}
|
68
|
+
|
69
|
+
markup.push(
|
70
|
+
'<circle ',
|
71
|
+
'cx="0" cy="0" ',
|
72
|
+
'r="', this.radius,
|
73
|
+
'" style="', this.getSvgStyles(),
|
74
|
+
'" transform="', this.getSvgTransform(),
|
75
|
+
'"/>'
|
76
|
+
);
|
77
|
+
|
78
|
+
return markup.join('');
|
68
79
|
},
|
80
|
+
/* _TO_SVG_END_ */
|
69
81
|
|
70
82
|
/**
|
71
83
|
* @private
|
72
|
-
* @method _render
|
73
84
|
* @param ctx {CanvasRenderingContext2D} context to render on
|
74
85
|
*/
|
75
86
|
_render: function(ctx, noTransform) {
|
@@ -78,18 +89,13 @@
|
|
78
89
|
ctx.globalAlpha = this.group ? (ctx.globalAlpha * this.opacity) : this.opacity;
|
79
90
|
ctx.arc(noTransform ? this.left : 0, noTransform ? this.top : 0, this.radius, 0, piBy2, false);
|
80
91
|
ctx.closePath();
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
this._removeShadow(ctx);
|
85
|
-
if (this.stroke) {
|
86
|
-
ctx.stroke();
|
87
|
-
}
|
92
|
+
|
93
|
+
this._renderFill(ctx);
|
94
|
+
this._renderStroke(ctx);
|
88
95
|
},
|
89
96
|
|
90
97
|
/**
|
91
98
|
* Returns horizontal radius of an object (according to how an object is scaled)
|
92
|
-
* @method getRadiusX
|
93
99
|
* @return {Number}
|
94
100
|
*/
|
95
101
|
getRadiusX: function() {
|
@@ -98,7 +104,6 @@
|
|
98
104
|
|
99
105
|
/**
|
100
106
|
* Returns vertical radius of an object (according to how an object is scaled)
|
101
|
-
* @method getRadiusY
|
102
107
|
* @return {Number}
|
103
108
|
*/
|
104
109
|
getRadiusY: function() {
|
@@ -107,7 +112,6 @@
|
|
107
112
|
|
108
113
|
/**
|
109
114
|
* Sets radius of an object (and updates width accordingly)
|
110
|
-
* @method setRadius
|
111
115
|
* @return {Number}
|
112
116
|
*/
|
113
117
|
setRadius: function(value) {
|
@@ -117,7 +121,6 @@
|
|
117
121
|
|
118
122
|
/**
|
119
123
|
* Returns complexity of an instance
|
120
|
-
* @method complexity
|
121
124
|
* @return {Number} complexity of this instance
|
122
125
|
*/
|
123
126
|
complexity: function() {
|
@@ -125,21 +128,21 @@
|
|
125
128
|
}
|
126
129
|
});
|
127
130
|
|
131
|
+
/* _FROM_SVG_START_ */
|
128
132
|
/**
|
129
133
|
* List of attribute names to account for when parsing SVG element (used by {@link fabric.Circle.fromElement})
|
130
134
|
* @static
|
131
135
|
* @see: http://www.w3.org/TR/SVG/shapes.html#CircleElement
|
132
136
|
*/
|
133
|
-
fabric.Circle.ATTRIBUTE_NAMES = 'cx cy r
|
137
|
+
fabric.Circle.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat('cx cy r'.split(' '));
|
134
138
|
|
135
139
|
/**
|
136
140
|
* Returns {@link fabric.Circle} instance from an SVG element
|
137
141
|
* @static
|
138
|
-
* @method fabric.Circle.fromElement
|
139
142
|
* @param {SVGElement} element Element to parse
|
140
143
|
* @param {Object} [options] Options object
|
141
144
|
* @throws {Error} If value of `r` attribute is missing or invalid
|
142
|
-
* @return {
|
145
|
+
* @return {fabric.Circle} Instance of fabric.Circle
|
143
146
|
*/
|
144
147
|
fabric.Circle.fromElement = function(element, options) {
|
145
148
|
options || (options = { });
|
@@ -167,11 +170,11 @@
|
|
167
170
|
function isValidRadius(attributes) {
|
168
171
|
return (('radius' in attributes) && (attributes.radius > 0));
|
169
172
|
}
|
173
|
+
/* _FROM_SVG_END_ */
|
170
174
|
|
171
175
|
/**
|
172
176
|
* Returns {@link fabric.Circle} instance from an object representation
|
173
177
|
* @static
|
174
|
-
* @method fabric.Circle.fromObject
|
175
178
|
* @param {Object} object Object to create an instance from
|
176
179
|
* @return {Object} Instance of fabric.Circle
|
177
180
|
*/
|
@@ -179,4 +182,4 @@
|
|
179
182
|
return new fabric.Circle(object);
|
180
183
|
};
|
181
184
|
|
182
|
-
})(typeof exports !== 'undefined' ? exports : this);
|
185
|
+
})(typeof exports !== 'undefined' ? exports : this);
|