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
@@ -3,14 +3,13 @@
|
|
3
3
|
var getPointer = fabric.util.getPointer,
|
4
4
|
degreesToRadians = fabric.util.degreesToRadians;
|
5
5
|
|
6
|
-
fabric.util.object.extend(fabric.Object.prototype, /** @
|
6
|
+
fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ {
|
7
7
|
|
8
8
|
/**
|
9
9
|
* Determines which one of the four corners has been clicked
|
10
|
-
* @method _findTargetCorner
|
11
10
|
* @private
|
12
|
-
* @param
|
13
|
-
* @param
|
11
|
+
* @param {Event} e Event object
|
12
|
+
* @param {Object} offset Canvas offset
|
14
13
|
* @return {String|Boolean} corner code (tl, tr, bl, br, etc.), or false if nothing is found
|
15
14
|
*/
|
16
15
|
_findTargetCorner: function(e, offset) {
|
@@ -19,7 +18,7 @@
|
|
19
18
|
var pointer = getPointer(e, this.canvas.upperCanvasEl),
|
20
19
|
ex = pointer.x - offset.left,
|
21
20
|
ey = pointer.y - offset.top,
|
22
|
-
|
21
|
+
xPoints,
|
23
22
|
lines;
|
24
23
|
|
25
24
|
for (var i in this.oCoords) {
|
@@ -32,7 +31,7 @@
|
|
32
31
|
continue;
|
33
32
|
}
|
34
33
|
|
35
|
-
lines = this._getImageLines(this.oCoords[i].corner
|
34
|
+
lines = this._getImageLines(this.oCoords[i].corner);
|
36
35
|
|
37
36
|
// debugging
|
38
37
|
|
@@ -48,8 +47,8 @@
|
|
48
47
|
// canvas.contextTop.fillRect(lines.rightline.d.x, lines.rightline.d.y, 2, 2);
|
49
48
|
// canvas.contextTop.fillRect(lines.rightline.o.x, lines.rightline.o.y, 2, 2);
|
50
49
|
|
51
|
-
|
52
|
-
if (
|
50
|
+
xPoints = this._findCrossPoints({x: ex, y: ey}, lines);
|
51
|
+
if (xPoints !== 0 && xPoints % 2 === 1) {
|
53
52
|
this.__corner = i;
|
54
53
|
return i;
|
55
54
|
}
|
@@ -57,88 +56,9 @@
|
|
57
56
|
return false;
|
58
57
|
},
|
59
58
|
|
60
|
-
/**
|
61
|
-
* Helper method to determine how many cross points are between the 4 image edges
|
62
|
-
* and the horizontal line determined by the position of our mouse when clicked on canvas
|
63
|
-
* @method _findCrossPoints
|
64
|
-
* @private
|
65
|
-
* @param ex {Number} x coordinate of the mouse
|
66
|
-
* @param ey {Number} y coordinate of the mouse
|
67
|
-
* @param oCoords {Object} Coordinates of the image being evaluated
|
68
|
-
*/
|
69
|
-
_findCrossPoints: function(ex, ey, oCoords) {
|
70
|
-
var b1, b2, a1, a2, xi, yi,
|
71
|
-
xcount = 0,
|
72
|
-
iLine;
|
73
|
-
|
74
|
-
for (var lineKey in oCoords) {
|
75
|
-
iLine = oCoords[lineKey];
|
76
|
-
// optimisation 1: line below dot. no cross
|
77
|
-
if ((iLine.o.y < ey) && (iLine.d.y < ey)) {
|
78
|
-
continue;
|
79
|
-
}
|
80
|
-
// optimisation 2: line above dot. no cross
|
81
|
-
if ((iLine.o.y >= ey) && (iLine.d.y >= ey)) {
|
82
|
-
continue;
|
83
|
-
}
|
84
|
-
// optimisation 3: vertical line case
|
85
|
-
if ((iLine.o.x === iLine.d.x) && (iLine.o.x >= ex)) {
|
86
|
-
xi = iLine.o.x;
|
87
|
-
yi = ey;
|
88
|
-
}
|
89
|
-
// calculate the intersection point
|
90
|
-
else {
|
91
|
-
b1 = 0;
|
92
|
-
b2 = (iLine.d.y-iLine.o.y)/(iLine.d.x-iLine.o.x);
|
93
|
-
a1 = ey-b1*ex;
|
94
|
-
a2 = iLine.o.y-b2*iLine.o.x;
|
95
|
-
|
96
|
-
xi = - (a1-a2)/(b1-b2);
|
97
|
-
yi = a1+b1*xi;
|
98
|
-
}
|
99
|
-
// dont count xi < ex cases
|
100
|
-
if (xi >= ex) {
|
101
|
-
xcount += 1;
|
102
|
-
}
|
103
|
-
// optimisation 4: specific for square images
|
104
|
-
if (xcount === 2) {
|
105
|
-
break;
|
106
|
-
}
|
107
|
-
}
|
108
|
-
return xcount;
|
109
|
-
},
|
110
|
-
|
111
|
-
/**
|
112
|
-
* Method that returns an object with the image lines in it given the coordinates of the corners
|
113
|
-
* @method _getImageLines
|
114
|
-
* @private
|
115
|
-
* @param oCoords {Object} coordinates of the image corners
|
116
|
-
*/
|
117
|
-
_getImageLines: function(oCoords) {
|
118
|
-
return {
|
119
|
-
topline: {
|
120
|
-
o: oCoords.tl,
|
121
|
-
d: oCoords.tr
|
122
|
-
},
|
123
|
-
rightline: {
|
124
|
-
o: oCoords.tr,
|
125
|
-
d: oCoords.br
|
126
|
-
},
|
127
|
-
bottomline: {
|
128
|
-
o: oCoords.br,
|
129
|
-
d: oCoords.bl
|
130
|
-
},
|
131
|
-
leftline: {
|
132
|
-
o: oCoords.bl,
|
133
|
-
d: oCoords.tl
|
134
|
-
}
|
135
|
-
};
|
136
|
-
},
|
137
|
-
|
138
59
|
/**
|
139
60
|
* Sets the coordinates of the draggable boxes in the corners of
|
140
61
|
* the image used to scale/rotate it.
|
141
|
-
* @method _setCornerCoords
|
142
62
|
* @private
|
143
63
|
*/
|
144
64
|
_setCornerCoords: function() {
|
@@ -326,13 +246,12 @@
|
|
326
246
|
* Draws borders of an object's bounding box.
|
327
247
|
* Requires public properties: width, height
|
328
248
|
* Requires public options: padding, borderColor
|
329
|
-
* @method drawBorders
|
330
249
|
* @param {CanvasRenderingContext2D} ctx Context to draw on
|
331
250
|
* @return {fabric.Object} thisArg
|
332
251
|
* @chainable
|
333
252
|
*/
|
334
253
|
drawBorders: function(ctx) {
|
335
|
-
if (!this.hasBorders) return;
|
254
|
+
if (!this.hasBorders) return this;
|
336
255
|
|
337
256
|
var padding = this.padding,
|
338
257
|
padding2 = padding * 2,
|
@@ -383,17 +302,16 @@
|
|
383
302
|
* Draws corners of an object's bounding box.
|
384
303
|
* Requires public properties: width, height, scaleX, scaleY
|
385
304
|
* Requires public options: cornerSize, padding
|
386
|
-
* @method drawControls
|
387
305
|
* @param {CanvasRenderingContext2D} ctx Context to draw on
|
388
306
|
* @return {fabric.Object} thisArg
|
389
307
|
* @chainable
|
390
308
|
*/
|
391
309
|
drawControls: function(ctx) {
|
392
|
-
if (!this.hasControls) return;
|
310
|
+
if (!this.hasControls) return this;
|
393
311
|
|
394
312
|
var size = this.cornerSize,
|
395
313
|
size2 = size / 2,
|
396
|
-
strokeWidth2 = this.strokeWidth / 2,
|
314
|
+
strokeWidth2 = this.strokeWidth > 1 ? (this.strokeWidth / 2) : 0,
|
397
315
|
left = -(this.width / 2),
|
398
316
|
top = -(this.height / 2),
|
399
317
|
_left,
|
@@ -409,6 +327,7 @@
|
|
409
327
|
height = this.height,
|
410
328
|
width = this.width,
|
411
329
|
methodName = this.transparentCorners ? 'strokeRect' : 'fillRect',
|
330
|
+
transparent = this.transparentCorners,
|
412
331
|
isVML = typeof G_vmlCanvasManager !== 'undefined';
|
413
332
|
|
414
333
|
ctx.save();
|
@@ -422,28 +341,28 @@
|
|
422
341
|
_left = left - scaleOffsetX - strokeWidth2 - paddingX;
|
423
342
|
_top = top - scaleOffsetY - strokeWidth2 - paddingY;
|
424
343
|
|
425
|
-
isVML || ctx.clearRect(_left, _top, sizeX, sizeY);
|
344
|
+
isVML || transparent || ctx.clearRect(_left, _top, sizeX, sizeY);
|
426
345
|
ctx[methodName](_left, _top, sizeX, sizeY);
|
427
346
|
|
428
347
|
// top-right
|
429
348
|
_left = left + width - scaleOffsetX + strokeWidth2 + paddingX;
|
430
349
|
_top = top - scaleOffsetY - strokeWidth2 - paddingY;
|
431
350
|
|
432
|
-
isVML || ctx.clearRect(_left, _top, sizeX, sizeY);
|
351
|
+
isVML || transparent || ctx.clearRect(_left, _top, sizeX, sizeY);
|
433
352
|
ctx[methodName](_left, _top, sizeX, sizeY);
|
434
353
|
|
435
354
|
// bottom-left
|
436
355
|
_left = left - scaleOffsetX - strokeWidth2 - paddingX;
|
437
356
|
_top = top + height + scaleOffsetSizeY + strokeWidth2 + paddingY;
|
438
357
|
|
439
|
-
isVML || ctx.clearRect(_left, _top, sizeX, sizeY);
|
358
|
+
isVML || transparent || ctx.clearRect(_left, _top, sizeX, sizeY);
|
440
359
|
ctx[methodName](_left, _top, sizeX, sizeY);
|
441
360
|
|
442
361
|
// bottom-right
|
443
362
|
_left = left + width + scaleOffsetSizeX + strokeWidth2 + paddingX;
|
444
363
|
_top = top + height + scaleOffsetSizeY + strokeWidth2 + paddingY;
|
445
364
|
|
446
|
-
isVML || ctx.clearRect(_left, _top, sizeX, sizeY);
|
365
|
+
isVML || transparent || ctx.clearRect(_left, _top, sizeX, sizeY);
|
447
366
|
ctx[methodName](_left, _top, sizeX, sizeY);
|
448
367
|
|
449
368
|
if (!this.get('lockUniScaling')) {
|
@@ -451,28 +370,28 @@
|
|
451
370
|
_left = left + width/2 - scaleOffsetX;
|
452
371
|
_top = top - scaleOffsetY - strokeWidth2 - paddingY;
|
453
372
|
|
454
|
-
isVML || ctx.clearRect(_left, _top, sizeX, sizeY);
|
373
|
+
isVML || transparent || ctx.clearRect(_left, _top, sizeX, sizeY);
|
455
374
|
ctx[methodName](_left, _top, sizeX, sizeY);
|
456
375
|
|
457
376
|
// middle-bottom
|
458
377
|
_left = left + width/2 - scaleOffsetX;
|
459
378
|
_top = top + height + scaleOffsetSizeY + strokeWidth2 + paddingY;
|
460
379
|
|
461
|
-
isVML || ctx.clearRect(_left, _top, sizeX, sizeY);
|
380
|
+
isVML || transparent || ctx.clearRect(_left, _top, sizeX, sizeY);
|
462
381
|
ctx[methodName](_left, _top, sizeX, sizeY);
|
463
382
|
|
464
383
|
// middle-right
|
465
384
|
_left = left + width + scaleOffsetSizeX + strokeWidth2 + paddingX;
|
466
385
|
_top = top + height/2 - scaleOffsetY;
|
467
386
|
|
468
|
-
isVML || ctx.clearRect(_left, _top, sizeX, sizeY);
|
387
|
+
isVML || transparent || ctx.clearRect(_left, _top, sizeX, sizeY);
|
469
388
|
ctx[methodName](_left, _top, sizeX, sizeY);
|
470
389
|
|
471
390
|
// middle-left
|
472
391
|
_left = left - scaleOffsetX - strokeWidth2 - paddingX;
|
473
392
|
_top = top + height/2 - scaleOffsetY;
|
474
393
|
|
475
|
-
isVML || ctx.clearRect(_left, _top, sizeX, sizeY);
|
394
|
+
isVML || transparent || ctx.clearRect(_left, _top, sizeX, sizeY);
|
476
395
|
ctx[methodName](_left, _top, sizeX, sizeY);
|
477
396
|
}
|
478
397
|
|
@@ -484,7 +403,7 @@
|
|
484
403
|
(top + height + (this.rotatingPointOffset / this.scaleY) - sizeY/2 + strokeWidth2 + paddingY)
|
485
404
|
: (top - (this.rotatingPointOffset / this.scaleY) - sizeY/2 - strokeWidth2 - paddingY);
|
486
405
|
|
487
|
-
isVML || ctx.clearRect(_left, _top, sizeX, sizeY);
|
406
|
+
isVML || transparent || ctx.clearRect(_left, _top, sizeX, sizeY);
|
488
407
|
ctx[methodName](_left, _top, sizeX, sizeY);
|
489
408
|
}
|
490
409
|
|
@@ -493,4 +412,4 @@
|
|
493
412
|
return this;
|
494
413
|
}
|
495
414
|
});
|
496
|
-
})();
|
415
|
+
})();
|
data/vendor/assets/javascripts/fabric/{object_origin.mixin.js → mixins/object_origin.mixin.js}
RENAMED
@@ -2,11 +2,10 @@
|
|
2
2
|
|
3
3
|
var degreesToRadians = fabric.util.degreesToRadians;
|
4
4
|
|
5
|
-
fabric.util.object.extend(fabric.Object.prototype, /** @
|
5
|
+
fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ {
|
6
6
|
|
7
7
|
/**
|
8
8
|
* Translates the coordinates from origin to center coordinates (based on the object's dimensions)
|
9
|
-
* @method translateToCenterPoint
|
10
9
|
* @param {fabric.Point} point The point which corresponds to the originX and originY params
|
11
10
|
* @param {string} enum('left', 'center', 'right') Horizontal origin
|
12
11
|
* @param {string} enum('top', 'center', 'bottom') Vertical origin
|
@@ -16,17 +15,17 @@
|
|
16
15
|
var cx = point.x, cy = point.y;
|
17
16
|
|
18
17
|
if ( originX === "left" ) {
|
19
|
-
cx = point.x + this.getWidth() / 2;
|
18
|
+
cx = point.x + ( this.getWidth() + (this.strokeWidth*this.scaleX) )/ 2;
|
20
19
|
}
|
21
20
|
else if ( originX === "right" ) {
|
22
|
-
cx = point.x - this.getWidth() / 2;
|
21
|
+
cx = point.x - ( this.getWidth() + (this.strokeWidth*this.scaleX) ) / 2;
|
23
22
|
}
|
24
23
|
|
25
24
|
if ( originY === "top" ) {
|
26
|
-
cy = point.y + this.getHeight() / 2;
|
25
|
+
cy = point.y +( this.getHeight() + (this.strokeWidth*this.scaleY) ) / 2;
|
27
26
|
}
|
28
27
|
else if ( originY === "bottom" ) {
|
29
|
-
cy = point.y - this.getHeight() / 2;
|
28
|
+
cy = point.y - ( this.getHeight() + (this.strokeWidth*this.scaleY) ) / 2;
|
30
29
|
}
|
31
30
|
|
32
31
|
// Apply the reverse rotation to the point (it's already scaled properly)
|
@@ -35,7 +34,6 @@
|
|
35
34
|
|
36
35
|
/**
|
37
36
|
* Translates the coordinates from center to origin coordinates (based on the object's dimensions)
|
38
|
-
* @method translateToOriginPoint
|
39
37
|
* @param {fabric.Point} point The point which corresponds to center of the object
|
40
38
|
* @param {string} enum('left', 'center', 'right') Horizontal origin
|
41
39
|
* @param {string} enum('top', 'center', 'bottom') Vertical origin
|
@@ -46,16 +44,16 @@
|
|
46
44
|
|
47
45
|
// Get the point coordinates
|
48
46
|
if ( originX === "left" ) {
|
49
|
-
x = center.x - this.getWidth() / 2;
|
47
|
+
x = center.x - ( this.getWidth() + (this.strokeWidth*this.scaleX) ) / 2;
|
50
48
|
}
|
51
49
|
else if ( originX === "right" ) {
|
52
|
-
x = center.x + this.getWidth() / 2;
|
50
|
+
x = center.x + ( this.getWidth() + (this.strokeWidth*this.scaleX) ) / 2;
|
53
51
|
}
|
54
52
|
if ( originY === "top" ) {
|
55
|
-
y = center.y - this.getHeight() / 2;
|
53
|
+
y = center.y - ( this.getHeight() + (this.strokeWidth*this.scaleY) )/ 2;
|
56
54
|
}
|
57
55
|
else if ( originY === "bottom" ) {
|
58
|
-
y = center.y + this.getHeight() / 2;
|
56
|
+
y = center.y + ( this.getHeight() + (this.strokeWidth*this.scaleY) )/ 2;
|
59
57
|
}
|
60
58
|
|
61
59
|
// Apply the rotation to the point (it's already scaled properly)
|
@@ -64,7 +62,6 @@
|
|
64
62
|
|
65
63
|
/**
|
66
64
|
* Returns the real center coordinates of the object
|
67
|
-
* @method getCenterPoint
|
68
65
|
* @return {fabric.Point}
|
69
66
|
*/
|
70
67
|
getCenterPoint: function() {
|
@@ -74,7 +71,6 @@
|
|
74
71
|
|
75
72
|
/**
|
76
73
|
* Returns the coordinates of the object based on center coordinates
|
77
|
-
* @method getOriginPoint
|
78
74
|
* @param {fabric.Point} point The point which corresponds to the originX and originY params
|
79
75
|
* @return {fabric.Point}
|
80
76
|
*/
|
@@ -84,7 +80,6 @@
|
|
84
80
|
|
85
81
|
/**
|
86
82
|
* Returns the coordinates of the object as if it has a different origin
|
87
|
-
* @method getPointByOrigin
|
88
83
|
* @param {string} enum('left', 'center', 'right') Horizontal origin
|
89
84
|
* @param {string} enum('top', 'center', 'bottom') Vertical origin
|
90
85
|
* @return {fabric.Point}
|
@@ -97,7 +92,6 @@
|
|
97
92
|
|
98
93
|
/**
|
99
94
|
* Returns the point in local coordinates
|
100
|
-
* @method toLocalPoint
|
101
95
|
* @param {fabric.Point} The point relative to the global coordinate system
|
102
96
|
* @return {fabric.Point}
|
103
97
|
*/
|
@@ -107,20 +101,20 @@
|
|
107
101
|
var x, y;
|
108
102
|
if (originX !== undefined && originY !== undefined) {
|
109
103
|
if ( originX === "left" ) {
|
110
|
-
x = center.x - this.getWidth() / 2;
|
104
|
+
x = center.x - (this.getWidth() + this.strokeWidth*this.scaleX) / 2;
|
111
105
|
}
|
112
106
|
else if ( originX === "right" ) {
|
113
|
-
x = center.x + this.getWidth() / 2;
|
107
|
+
x = center.x + (this.getWidth() + this.strokeWidth*this.scaleX)/ 2;
|
114
108
|
}
|
115
109
|
else {
|
116
110
|
x = center.x;
|
117
111
|
}
|
118
112
|
|
119
113
|
if ( originY === "top" ) {
|
120
|
-
y = center.y - this.getHeight() / 2;
|
114
|
+
y = center.y - (this.getHeight() + this.strokeWidth*this.scaleY) / 2;
|
121
115
|
}
|
122
116
|
else if ( originY === "bottom" ) {
|
123
|
-
y = center.y + this.getHeight() / 2;
|
117
|
+
y = center.y + (this.getHeight() + this.strokeWidth*this.scaleY)/ 2;
|
124
118
|
}
|
125
119
|
else {
|
126
120
|
y = center.y;
|
@@ -136,7 +130,6 @@
|
|
136
130
|
|
137
131
|
/**
|
138
132
|
* Returns the point in global coordinates
|
139
|
-
* @method toGlobalPoint
|
140
133
|
* @param {fabric.Point} The point relative to the local coordinate system
|
141
134
|
* @return {fabric.Point}
|
142
135
|
*/
|
@@ -146,7 +139,6 @@
|
|
146
139
|
|
147
140
|
/**
|
148
141
|
* Sets the position of the object taking into consideration the object's origin
|
149
|
-
* @method setPositionByOrigin
|
150
142
|
* @param {fabric.Point} point The new position of the object
|
151
143
|
* @param {string} enum('left', 'center', 'right') Horizontal origin
|
152
144
|
* @param {string} enum('top', 'center', 'bottom') Vertical origin
|
@@ -161,17 +153,13 @@
|
|
161
153
|
},
|
162
154
|
|
163
155
|
/**
|
164
|
-
* @method adjustPosition
|
165
156
|
* @param {String} to One of left, center, right
|
166
157
|
*/
|
167
158
|
adjustPosition: function(to) {
|
168
|
-
|
169
159
|
var angle = degreesToRadians(this.angle);
|
170
|
-
|
171
160
|
var hypotHalf = this.getWidth() / 2;
|
172
161
|
var xHalf = Math.cos(angle) * hypotHalf;
|
173
162
|
var yHalf = Math.sin(angle) * hypotHalf;
|
174
|
-
|
175
163
|
var hypotFull = this.getWidth();
|
176
164
|
var xFull = Math.cos(angle) * hypotFull;
|
177
165
|
var yFull = Math.sin(angle) * hypotFull;
|
@@ -201,7 +189,29 @@
|
|
201
189
|
|
202
190
|
this.setCoords();
|
203
191
|
this.originX = to;
|
192
|
+
},
|
193
|
+
|
194
|
+
/**
|
195
|
+
* @private
|
196
|
+
*/
|
197
|
+
_getLeftTopCoords: function() {
|
198
|
+
var angle = degreesToRadians(this.angle);
|
199
|
+
|
200
|
+
var hypotHalf = this.getWidth() / 2;
|
201
|
+
var xHalf = Math.cos(angle) * hypotHalf;
|
202
|
+
var yHalf = Math.sin(angle) * hypotHalf;
|
203
|
+
var x = this.left;
|
204
|
+
var y = this.top;
|
205
|
+
|
206
|
+
if (this.originX === 'center' || this.originX === 'right') {
|
207
|
+
x -= xHalf;
|
208
|
+
}
|
209
|
+
if (this.originY === 'center' || this.originY === 'bottom') {
|
210
|
+
y -= yHalf;
|
211
|
+
}
|
212
|
+
|
213
|
+
return { x: x, y: y };
|
204
214
|
}
|
205
215
|
});
|
206
216
|
|
207
|
-
})();
|
217
|
+
})();
|
@@ -1,8 +1,7 @@
|
|
1
|
-
fabric.util.object.extend(fabric.Object.prototype, /** @
|
1
|
+
fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ {
|
2
2
|
|
3
3
|
/**
|
4
4
|
* @private
|
5
|
-
* @method _getAngleValueForStraighten
|
6
5
|
* @return {Number} angle value
|
7
6
|
*/
|
8
7
|
_getAngleValueForStraighten: function() {
|
@@ -15,7 +14,6 @@ fabric.util.object.extend(fabric.Object.prototype, /** @scope fabric.Object.prot
|
|
15
14
|
|
16
15
|
/**
|
17
16
|
* Straightens an object (rotating it from current angle to one of 0, 90, 180, 270, etc. depending on which is closer)
|
18
|
-
* @method straighten
|
19
17
|
* @return {fabric.Object} thisArg
|
20
18
|
* @chainable
|
21
19
|
*/
|
@@ -26,7 +24,6 @@ fabric.util.object.extend(fabric.Object.prototype, /** @scope fabric.Object.prot
|
|
26
24
|
|
27
25
|
/**
|
28
26
|
* Same as {@link fabric.Object.prototype.straghten} but with animation
|
29
|
-
* @method fxStraighten
|
30
27
|
* @param {Object} callbacks
|
31
28
|
* - onComplete: invoked on completion
|
32
29
|
* - onChange: invoked on every step of animation
|
@@ -55,7 +52,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @scope fabric.Object.prot
|
|
55
52
|
onComplete();
|
56
53
|
},
|
57
54
|
onStart: function() {
|
58
|
-
_this.
|
55
|
+
_this.set('active', false);
|
59
56
|
}
|
60
57
|
});
|
61
58
|
|
@@ -63,11 +60,10 @@ fabric.util.object.extend(fabric.Object.prototype, /** @scope fabric.Object.prot
|
|
63
60
|
}
|
64
61
|
});
|
65
62
|
|
66
|
-
fabric.util.object.extend(fabric.StaticCanvas.prototype, {
|
63
|
+
fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.StaticCanvas.prototype */ {
|
67
64
|
|
68
65
|
/**
|
69
66
|
* Straightens object, then rerenders canvas
|
70
|
-
* @method straightenObject
|
71
67
|
* @param {fabric.Object} object Object to straighten
|
72
68
|
* @return {fabric.Canvas} thisArg
|
73
69
|
* @chainable
|
@@ -80,7 +76,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
|
|
80
76
|
|
81
77
|
/**
|
82
78
|
* Same as {@link fabric.Canvas.prototype.straightenObject}, but animated
|
83
|
-
* @method fxStraightenObject
|
84
79
|
* @param {fabric.Object} object Object to straighten
|
85
80
|
* @return {fabric.Canvas} thisArg
|
86
81
|
* @chainable
|
@@ -91,4 +86,4 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
|
|
91
86
|
});
|
92
87
|
return this;
|
93
88
|
}
|
94
|
-
});
|
89
|
+
});
|