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.
Files changed (76) hide show
  1. data/CHANGELOG.md +4 -0
  2. data/README.md +1 -1
  3. data/lib/fabric/rails/version.rb +2 -2
  4. data/vendor/assets/javascripts/cufon.js +1226 -0
  5. data/vendor/assets/javascripts/event.js +20 -20
  6. data/vendor/assets/javascripts/excanvas.js +1464 -0
  7. data/vendor/assets/javascripts/fabric.js +56 -33
  8. data/vendor/assets/javascripts/fabric/HEADER.js +2 -4
  9. data/vendor/assets/javascripts/fabric/brushes/base_brush.class.js +96 -0
  10. data/vendor/assets/javascripts/fabric/brushes/circle_brush.class.js +99 -0
  11. data/vendor/assets/javascripts/fabric/brushes/pattern_brush.class.js +55 -0
  12. data/vendor/assets/javascripts/fabric/{freedrawing.class.js → brushes/pencil_brush.class.js} +73 -65
  13. data/vendor/assets/javascripts/fabric/brushes/spray_brush.class.js +157 -0
  14. data/vendor/assets/javascripts/fabric/canvas.class.js +154 -135
  15. data/vendor/assets/javascripts/fabric/color.class.js +195 -29
  16. data/vendor/assets/javascripts/fabric/filters/brightness_filter.class.js +70 -0
  17. data/vendor/assets/javascripts/fabric/filters/convolute_filter.class.js +122 -0
  18. data/vendor/assets/javascripts/fabric/filters/gradienttransparency_filter.class.js +69 -0
  19. data/vendor/assets/javascripts/fabric/filters/grayscale_filter.class.js +61 -0
  20. data/vendor/assets/javascripts/fabric/filters/invert_filter.class.js +57 -0
  21. data/vendor/assets/javascripts/fabric/filters/noise_filter.class.js +73 -0
  22. data/vendor/assets/javascripts/fabric/filters/pixelate_filter.class.js +98 -0
  23. data/vendor/assets/javascripts/fabric/filters/removewhite_filter.class.js +86 -0
  24. data/vendor/assets/javascripts/fabric/filters/sepia2_filter.class.js +61 -0
  25. data/vendor/assets/javascripts/fabric/filters/sepia_filter.class.js +58 -0
  26. data/vendor/assets/javascripts/fabric/filters/tint_filter.class.js +80 -0
  27. data/vendor/assets/javascripts/fabric/gradient.class.js +232 -80
  28. data/vendor/assets/javascripts/fabric/intersection.class.js +10 -28
  29. data/vendor/assets/javascripts/fabric/log.js +0 -2
  30. data/vendor/assets/javascripts/fabric/{canvas_animation.mixin.js → mixins/canvas_animation.mixin.js} +3 -6
  31. data/vendor/assets/javascripts/fabric/mixins/canvas_dataurl_exporter.mixin.js +137 -0
  32. data/vendor/assets/javascripts/fabric/{canvas_events.mixin.js → mixins/canvas_events.mixin.js} +97 -144
  33. data/vendor/assets/javascripts/fabric/{canvas_gestures.mixin.js → mixins/canvas_gestures.mixin.js} +4 -8
  34. data/vendor/assets/javascripts/fabric/{canvas_serialization.mixin.js → mixins/canvas_serialization.mixin.js} +19 -14
  35. data/vendor/assets/javascripts/fabric/mixins/collection.mixin.js +137 -0
  36. data/vendor/assets/javascripts/fabric/{object_geometry.mixin.js → mixins/object_geometry.mixin.js} +130 -47
  37. data/vendor/assets/javascripts/fabric/{object_interactivity.mixin.js → mixins/object_interactivity.mixin.js} +21 -102
  38. data/vendor/assets/javascripts/fabric/{object_origin.mixin.js → mixins/object_origin.mixin.js} +36 -26
  39. data/vendor/assets/javascripts/fabric/{object_straightening.mixin.js → mixins/object_straightening.mixin.js} +4 -9
  40. data/vendor/assets/javascripts/fabric/{observable.mixin.js → mixins/observable.mixin.js} +27 -35
  41. data/vendor/assets/javascripts/fabric/mixins/stateful.mixin.js +45 -0
  42. data/vendor/assets/javascripts/fabric/node.js +62 -26
  43. data/vendor/assets/javascripts/fabric/parser.js +181 -58
  44. data/vendor/assets/javascripts/fabric/pattern.class.js +43 -14
  45. data/vendor/assets/javascripts/fabric/point.class.js +4 -43
  46. data/vendor/assets/javascripts/fabric/shadow.class.js +19 -19
  47. data/vendor/assets/javascripts/fabric/{circle.class.js → shapes/circle.class.js} +32 -29
  48. data/vendor/assets/javascripts/fabric/{ellipse.class.js → shapes/ellipse.class.js} +45 -27
  49. data/vendor/assets/javascripts/fabric/{group.class.js → shapes/group.class.js} +67 -169
  50. data/vendor/assets/javascripts/fabric/{image.class.js → shapes/image.class.js} +134 -72
  51. data/vendor/assets/javascripts/fabric/{line.class.js → shapes/line.class.js} +67 -36
  52. data/vendor/assets/javascripts/fabric/{object.class.js → shapes/object.class.js} +394 -252
  53. data/vendor/assets/javascripts/fabric/{path.class.js → shapes/path.class.js} +89 -174
  54. data/vendor/assets/javascripts/fabric/{path_group.class.js → shapes/path_group.class.js} +12 -18
  55. data/vendor/assets/javascripts/fabric/{polygon.class.js → shapes/polygon.class.js} +64 -38
  56. data/vendor/assets/javascripts/fabric/{polyline.class.js → shapes/polyline.class.js} +64 -39
  57. data/vendor/assets/javascripts/fabric/{rect.class.js → shapes/rect.class.js} +78 -112
  58. data/vendor/assets/javascripts/fabric/{text.class.js → shapes/text.class.js} +264 -270
  59. data/vendor/assets/javascripts/fabric/shapes/text.cufon.js +79 -0
  60. data/vendor/assets/javascripts/fabric/{triangle.class.js → shapes/triangle.class.js} +46 -26
  61. data/vendor/assets/javascripts/fabric/static_canvas.class.js +134 -358
  62. data/vendor/assets/javascripts/fabric/util/anim_ease.js +2 -31
  63. data/vendor/assets/javascripts/fabric/util/dom_event.js +21 -7
  64. data/vendor/assets/javascripts/fabric/util/dom_misc.js +49 -39
  65. data/vendor/assets/javascripts/fabric/util/dom_request.js +1 -2
  66. data/vendor/assets/javascripts/fabric/util/dom_style.js +1 -2
  67. data/vendor/assets/javascripts/fabric/util/lang_array.js +19 -13
  68. data/vendor/assets/javascripts/fabric/util/lang_class.js +1 -2
  69. data/vendor/assets/javascripts/fabric/util/lang_function.js +3 -1
  70. data/vendor/assets/javascripts/fabric/util/lang_object.js +5 -5
  71. data/vendor/assets/javascripts/fabric/util/lang_string.js +7 -5
  72. data/vendor/assets/javascripts/fabric/util/misc.js +207 -42
  73. metadata +47 -29
  74. data/vendor/assets/javascripts/fabric/image_filters.js +0 -809
  75. data/vendor/assets/javascripts/fabric/scout.js +0 -45
  76. data/vendor/assets/javascripts/fabric/stateful.js +0 -88
@@ -7,7 +7,8 @@
7
7
  //= require event.js
8
8
  //
9
9
  //= require fabric/log.js
10
- //= require fabric/observable.mixin.js
10
+ //= require fabric/mixins/observable.mixin.js
11
+ //= require fabric/mixins/collection.mixin.js
11
12
  //
12
13
  //= require fabric/util/misc.js
13
14
  //= require fabric/util/lang_array.js
@@ -23,42 +24,64 @@
23
24
  //= require fabric/util/anim_ease.js
24
25
  //= require fabric/parser.js
25
26
  //
26
- //= require fabric/gradient.class.js
27
- //= require fabric/pattern.class.js
28
- //= require fabric/shadow.class.js
29
27
  //= require fabric/point.class.js
30
28
  //= require fabric/intersection.class.js
31
29
  //= require fabric/color.class.js
30
+ //
31
+ //= require fabric/gradient.class.js
32
+ //= require fabric/pattern.class.js
33
+ //= require fabric/shadow.class.js
34
+ //
32
35
  //= require fabric/static_canvas.class.js
33
36
  //
34
- //= require fabric/freedrawing.class.js
37
+ //= require fabric/brushes/base_brush.class.js
38
+ //= require fabric/brushes/pencil_brush.class.js
39
+ //= require fabric/brushes/circle_brush.class.js
40
+ //= require fabric/brushes/spray_brush.class.js
41
+ //= require fabric/brushes/pattern_brush.class.js
42
+ //
35
43
  //= require fabric/canvas.class.js
36
- //= require fabric/canvas_events.mixin.js
37
- //
38
- //= require fabric/canvas_animation.mixin.js
39
- //
40
- //= require fabric/canvas_serialization.mixin.js
41
- //= require fabric/canvas_gestures.mixin.js
42
- //
43
- //= require fabric/object.class.js
44
- //= require fabric/object_origin.mixin.js
45
- //= require fabric/object_geometry.mixin.js
46
- //
47
- //= require fabric/object_interactivity.mixin.js
48
- //
49
- //= require fabric/line.class.js
50
- //= require fabric/circle.class.js
51
- //= require fabric/triangle.class.js
52
- //= require fabric/ellipse.class.js
53
- //= require fabric/rect.class.js
54
- //= require fabric/polyline.class.js
55
- //= require fabric/polygon.class.js
56
- //= require fabric/path.class.js
57
- //= require fabric/path_group.class.js
58
- //= require fabric/group.class.js
59
- //= require fabric/image.class.js
60
- //
61
- //= require fabric/object_straightening.mixin.js
62
- //= require fabric/image_filters.js
63
- //= require fabric/text.class.js
44
+ //= require fabric/mixins/canvas_events.mixin.js
45
+ //
46
+ //= require fabric/mixins/canvas_animation.mixin.js
47
+ //= require fabric/mixins/canvas_dataurl_exporter.mixin.js
48
+ //
49
+ //= require fabric/mixins/canvas_serialization.mixin.js
50
+ //= require fabric/mixins/canvas_gestures.mixin.js
51
+ //
52
+ //= require fabric/shapes/object.class.js
53
+ //= require fabric/mixins/object_origin.mixin.js
54
+ //= require fabric/mixins/object_geometry.mixin.js
55
+ //= require fabric/mixins/stateful.mixin.js
56
+ //
57
+ //= require fabric/mixins/object_interactivity.mixin.js
58
+ //
59
+ //= require fabric/shapes/line.class.js
60
+ //= require fabric/shapes/circle.class.js
61
+ //= require fabric/shapes/triangle.class.js
62
+ //= require fabric/shapes/ellipse.class.js
63
+ //= require fabric/shapes/rect.class.js
64
+ //= require fabric/shapes/polyline.class.js
65
+ //= require fabric/shapes/polygon.class.js
66
+ //= require fabric/shapes/path.class.js
67
+ //= require fabric/shapes/path_group.class.js
68
+ //= require fabric/shapes/group.class.js
69
+ //= require fabric/shapes/image.class.js
70
+ //
71
+ //= require fabric/mixins/object_straightening.mixin.js
72
+ //
73
+ //= require fabric/filters/brightness_filter.class.js
74
+ //= require fabric/filters/convolute_filter.class.js
75
+ //= require fabric/filters/gradienttransparency_filter.class.js
76
+ //= require fabric/filters/grayscale_filter.class.js
77
+ //= require fabric/filters/invert_filter.class.js
78
+ //= require fabric/filters/noise_filter.class.js
79
+ //= require fabric/filters/pixelate_filter.class.js
80
+ //= require fabric/filters/removewhite_filter.class.js
81
+ //= require fabric/filters/sepia_filter.class.js
82
+ //= require fabric/filters/sepia2_filter.class.js
83
+ //= require fabric/filters/tint_filter.class.js
84
+
85
+ //= require fabric/shapes/text.class.js
86
+ //= require fabric/shapes/text.cufon.js
64
87
  //
@@ -1,6 +1,6 @@
1
1
  /*! Fabric.js Copyright 2008-2013, Printio (Juriy Zaytsev, Maxim Chernyak) */
2
2
 
3
- var fabric = fabric || { version: "1.0.12" };
3
+ var fabric = fabric || { version: "1.2.1" };
4
4
 
5
5
  if (typeof exports !== 'undefined') {
6
6
  exports.fabric = fabric;
@@ -18,14 +18,12 @@ else {
18
18
 
19
19
  /**
20
20
  * True when in environment that supports touch events
21
- * @property isTouchSupported
22
21
  * @type boolean
23
22
  */
24
23
  fabric.isTouchSupported = "ontouchstart" in fabric.document.documentElement;
25
24
 
26
25
  /**
27
26
  * True when in environment that's probably Node.js
28
- * @property isLikelyNode
29
27
  * @type boolean
30
28
  */
31
- fabric.isLikelyNode = typeof Buffer !== 'undefined' && typeof window === 'undefined';
29
+ fabric.isLikelyNode = typeof Buffer !== 'undefined' && typeof window === 'undefined';
@@ -0,0 +1,96 @@
1
+ /**
2
+ * BaseBrush class
3
+ * @class fabric.BaseBrush
4
+ */
5
+ fabric.BaseBrush = fabric.util.createClass(/** @lends fabric.BaseBrush.prototype */ {
6
+
7
+ /**
8
+ * Color of a brush
9
+ * @type String
10
+ * @default
11
+ */
12
+ color: 'rgb(0, 0, 0)',
13
+
14
+ /**
15
+ * Width of a brush
16
+ * @type Number
17
+ * @default
18
+ */
19
+ width: 1,
20
+
21
+ /**
22
+ * Shadow blur of a brush
23
+ * @type Number
24
+ * @default
25
+ */
26
+ shadowBlur: 0,
27
+
28
+ /**
29
+ * Shadow color of a brush
30
+ * @type String
31
+ * @default
32
+ */
33
+ shadowColor: '',
34
+
35
+ /**
36
+ * Shadow offset x of a brush
37
+ * @type Number
38
+ * @default
39
+ */
40
+ shadowOffsetX: 0,
41
+
42
+ /**
43
+ * Shadow offset y of a brush
44
+ * @type Number
45
+ * @default
46
+ */
47
+ shadowOffsetY: 0,
48
+
49
+ /**
50
+ * Line endings style of a brush (one of "butt", "round", "square")
51
+ * @type String
52
+ * @default
53
+ */
54
+ strokeLineCap: 'round',
55
+
56
+ /**
57
+ * Corner style of a brush (one of "bevil", "round", "miter")
58
+ * @type String
59
+ * @default
60
+ */
61
+ strokeLineJoin: 'round',
62
+
63
+ /**
64
+ * Sets brush styles
65
+ */
66
+ setBrushStyles: function() {
67
+ var ctx = this.canvas.contextTop;
68
+
69
+ ctx.strokeStyle = this.color;
70
+ ctx.lineWidth = this.width;
71
+ ctx.lineCap = this.strokeLineCap;
72
+ ctx.lineJoin = this.strokeLineJoin;
73
+ },
74
+
75
+ /**
76
+ * Sets brush shadow styles
77
+ */
78
+ setShadowStyles: function() {
79
+ var ctx = this.canvas.contextTop;
80
+
81
+ ctx.shadowBlur = this.shadowBlur;
82
+ ctx.shadowColor = this.shadowColor || this.color;
83
+ ctx.shadowOffsetX = this.shadowOffsetX;
84
+ ctx.shadowOffsetY = this.shadowOffsetY;
85
+ },
86
+
87
+ /**
88
+ * Remove brush shadow styles
89
+ */
90
+ removeShadowStyles: function() {
91
+ var ctx = this.canvas.contextTop;
92
+
93
+ ctx.shadowColor = '';
94
+ ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;
95
+ }
96
+ });
@@ -0,0 +1,99 @@
1
+ /**
2
+ * CircleBrush class
3
+ * @class fabric.CircleBrush
4
+ */
5
+ fabric.CircleBrush = fabric.util.createClass( fabric.BaseBrush, /** @lends fabric.CircleBrush.prototype */ {
6
+
7
+ /**
8
+ * Width of a brush
9
+ * @type Number
10
+ */
11
+ width: 10,
12
+
13
+ /**
14
+ * Constructor
15
+ * @param {fabric.Canvas} canvas
16
+ * @return {fabric.CircleBrush} Instance of a circle brush
17
+ */
18
+ initialize: function(canvas) {
19
+ this.canvas = canvas;
20
+ this.points = [ ];
21
+ },
22
+
23
+ /**
24
+ * Invoked on mouse down
25
+ * @param {Object} pointer
26
+ */
27
+ onMouseDown: function() {
28
+ this.points.length = 0;
29
+ this.canvas.clearContext(this.canvas.contextTop);
30
+ this.setShadowStyles();
31
+ },
32
+
33
+ /**
34
+ * Invoked on mouse move
35
+ * @param {Object} pointer
36
+ */
37
+ onMouseMove: function(pointer) {
38
+ var point = this.addPoint(pointer);
39
+ var ctx = this.canvas.contextTop;
40
+
41
+ ctx.fillStyle = point.fill;
42
+ ctx.beginPath();
43
+ ctx.arc(point.x, point.y, point.radius, 0, Math.PI * 2, false);
44
+ ctx.closePath();
45
+ ctx.fill();
46
+ },
47
+
48
+ /**
49
+ * Invoked on mouse up
50
+ */
51
+ onMouseUp: function() {
52
+ var originalRenderOnAddition = this.canvas.renderOnAddition;
53
+ this.canvas.renderOnAddition = false;
54
+
55
+ for (var i = 0, len = this.points.length; i < len; i++) {
56
+ var point = this.points[i];
57
+ var circle = new fabric.Circle({
58
+ radius: point.radius,
59
+ left: point.x,
60
+ top: point.y,
61
+ fill: point.fill,
62
+ shadow: {
63
+ color: this.shadowColor || this.color,
64
+ blur: this.shadowBlur,
65
+ offsetX: this.shadowOffsetX,
66
+ offsetY: this.shadowOffsetY
67
+ }
68
+ });
69
+ this.canvas.add(circle);
70
+ }
71
+
72
+ this.canvas.clearContext(this.canvas.contextTop);
73
+ this.removeShadowStyles();
74
+ this.canvas.renderOnAddition = originalRenderOnAddition;
75
+ this.canvas.renderAll();
76
+ },
77
+
78
+ /**
79
+ * @param {Object} pointer
80
+ * @return {fabric.Point} Just added pointer point
81
+ */
82
+ addPoint: function(pointer) {
83
+ var pointerPoint = new fabric.Point(pointer.x, pointer.y);
84
+
85
+ var circleRadius = fabric.util.getRandomInt(
86
+ Math.max(0, this.width - 20), this.width + 20) / 2;
87
+
88
+ var circleColor = new fabric.Color(this.color)
89
+ .setAlpha(fabric.util.getRandomInt(0, 100) / 100)
90
+ .toRgba();
91
+
92
+ pointerPoint.radius = circleRadius;
93
+ pointerPoint.fill = circleColor;
94
+
95
+ this.points.push(pointerPoint);
96
+
97
+ return pointerPoint;
98
+ }
99
+ });
@@ -0,0 +1,55 @@
1
+ /**
2
+ * PatternBrush class
3
+ * @class fabric.PatternBrush
4
+ * @extends fabric.BaseBrush
5
+ */
6
+ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fabric.PatternBrush.prototype */ {
7
+
8
+ getPatternSrc: function() {
9
+
10
+ var dotWidth = 20,
11
+ dotDistance = 5,
12
+ patternCanvas = fabric.document.createElement('canvas'),
13
+ patternCtx = patternCanvas.getContext('2d');
14
+
15
+ patternCanvas.width = patternCanvas.height = dotWidth + dotDistance;
16
+
17
+ patternCtx.fillStyle = this.color;
18
+ patternCtx.beginPath();
19
+ patternCtx.arc(dotWidth / 2, dotWidth / 2, dotWidth / 2, 0, Math.PI * 2, false);
20
+ patternCtx.closePath();
21
+ patternCtx.fill();
22
+
23
+ return patternCanvas;
24
+ },
25
+
26
+ getPatternSrcFunction: function() {
27
+ return String(this.getPatternSrc).replace('this.color', '"' + this.color + '"');
28
+ },
29
+
30
+ /**
31
+ * Creates "pattern" instance property
32
+ */
33
+ getPattern: function() {
34
+ return this.canvas.contextTop.createPattern(this.source || this.getPatternSrc(), 'repeat');
35
+ },
36
+
37
+ /**
38
+ * Sets brush styles
39
+ */
40
+ setBrushStyles: function() {
41
+ this.callSuper('setBrushStyles');
42
+ this.canvas.contextTop.strokeStyle = this.getPattern();
43
+ },
44
+
45
+ /**
46
+ * Creates path
47
+ */
48
+ createPath: function(pathData) {
49
+ var path = this.callSuper('createPath', pathData);
50
+ path.stroke = new fabric.Pattern({
51
+ source: this.source || this.getPatternSrcFunction()
52
+ });
53
+ return path;
54
+ }
55
+ });
@@ -1,42 +1,71 @@
1
- (function(global) {
2
-
3
- "use strict";
4
-
5
- var fabric = global.fabric || (global.fabric = { });
1
+ (function() {
6
2
 
7
3
  var utilMin = fabric.util.array.min,
8
4
  utilMax = fabric.util.array.max;
9
5
 
10
- if (fabric.FreeDrawing) {
11
- fabric.warn('fabric.FreeDrawing is already defined');
12
- return;
13
- }
14
-
15
6
  /**
16
- * Free drawing class
17
- * Free Drawer handles scribbling on a fabric canvas
18
- * It converts the hand writting to a SVG Path and adds this path to the canvas
19
- *
20
- * @class FreeDrawing
21
- * @memberOf fabric
7
+ * PencilBrush class
8
+ * @class fabric.PencilBrush
9
+ * @extends fabric.BaseBrush
22
10
  */
23
- fabric.FreeDrawing = fabric.util.createClass( /** @scope fabric.FreeDrawing.prototype */ {
11
+ fabric.PencilBrush = fabric.util.createClass( fabric.BaseBrush, /** @lends fabric.PencilBrush.prototype */ {
24
12
 
25
13
  /**
26
14
  * Constructor
27
- * @metod initialize
28
- * @param fabricCanvas {fabric.Canvas}
29
- * @return {fabric.FreeDrawing}
15
+ * @param {fabric.Canvas} canvas
16
+ * @return {fabric.PencilBrush} Instance of a pencil brush
17
+ */
18
+ initialize: function(canvas) {
19
+ this.canvas = canvas;
20
+ this._points = [ ];
21
+ },
22
+
23
+ /**
24
+ * Inovoked on mouse down
25
+ * @param {Object} pointer
26
+ */
27
+ onMouseDown: function(pointer) {
28
+ this._prepareForDrawing(pointer);
29
+ // capture coordinates immediately
30
+ // this allows to draw dots (when movement never occurs)
31
+ this._captureDrawingPath(pointer);
32
+ },
33
+
34
+ /**
35
+ * Inovoked on mouse move
36
+ * @param {Object} pointer
30
37
  */
31
- initialize: function(fabricCanvas) {
32
- this.canvas = fabricCanvas;
33
- this._points = [];
38
+ onMouseMove: function(pointer) {
39
+ this._captureDrawingPath(pointer);
40
+ // redraw curve
41
+ // clear top canvas
42
+ this.canvas.clearContext(this.canvas.contextTop);
43
+ this._render(this.canvas.contextTop);
44
+ },
45
+
46
+ /**
47
+ * Invoked on mouse up
48
+ */
49
+ onMouseUp: function() {
50
+ this._finalizeAndAddPath();
51
+ },
52
+
53
+ /**
54
+ * @param {Object} pointer
55
+ */
56
+ _prepareForDrawing: function(pointer) {
57
+
58
+ var p = new fabric.Point(pointer.x, pointer.y);
59
+
60
+ this._reset();
61
+ this._addPoint(p);
62
+
63
+ this.canvas.contextTop.moveTo(p.x, p.y);
34
64
  },
35
65
 
36
66
  /**
37
67
  * @private
38
- * @method _addPoint
39
- *
68
+ * @param {fabric.Point} point
40
69
  */
41
70
  _addPoint: function(point) {
42
71
  this._points.push(point);
@@ -47,36 +76,17 @@
47
76
  * style.
48
77
  *
49
78
  * @private
50
- * @method _reset
51
79
  *
52
80
  */
53
81
  _reset: function() {
54
82
  this._points.length = 0;
55
- var ctx = this.canvas.contextTop;
56
-
57
- // set freehanddrawing line canvas parameters
58
- ctx.strokeStyle = this.canvas.freeDrawingColor;
59
- ctx.lineWidth = this.canvas.freeDrawingLineWidth;
60
- ctx.lineCap = ctx.lineJoin = 'round';
61
- },
62
-
63
- /**
64
- * @method _prepareForDrawing
65
- */
66
- _prepareForDrawing: function(pointer) {
67
-
68
- this.canvas._isCurrentlyDrawing = true;
69
- this.canvas.discardActiveObject().renderAll();
70
83
 
71
- var p = new fabric.Point(pointer.x, pointer.y);
72
- this._reset();
73
- this._addPoint(p);
74
- this.canvas.contextTop.moveTo(p.x, p.y);
84
+ this.setBrushStyles();
85
+ this.setShadowStyles();
75
86
  },
76
87
 
77
88
  /**
78
89
  * @private
79
- * @method _captureDrawingPath
80
90
  *
81
91
  * @param point {pointer} (fabric.util.pointer) actual mouse position
82
92
  * related to the canvas.
@@ -87,12 +97,9 @@
87
97
  },
88
98
 
89
99
  /**
90
- * Draw a smooth path on the topCanvas using
91
- * quadraticCurveTo.
100
+ * Draw a smooth path on the topCanvas using quadraticCurveTo
92
101
  *
93
102
  * @private
94
- * @method _render
95
- *
96
103
  */
97
104
  _render: function() {
98
105
  var ctx = this.canvas.contextTop;
@@ -120,12 +127,9 @@
120
127
  },
121
128
 
122
129
  /**
123
- * Return an SVG path based on our
124
- * captured points and their boundinb box.
130
+ * Return an SVG path based on our captured points and their bounding box
125
131
  *
126
132
  * @private
127
- * @method _getSVGPathData
128
- *
129
133
  */
130
134
  _getSVGPathData: function() {
131
135
  this.box = this.getPathBoundingBox(this._points);
@@ -135,7 +139,6 @@
135
139
 
136
140
  /**
137
141
  * Returns bounding box of a path based on given points
138
- * @method getPathBoundingBox
139
142
  * @param {Array} points
140
143
  * @return {Object} object with minx, miny, maxx, maxy
141
144
  */
@@ -172,11 +175,10 @@
172
175
 
173
176
  /**
174
177
  * Converts points to SVG path
175
- * @method convertPointsToSVGPath
176
178
  * @param {Array} points Array of points
177
179
  * @return {String} SVG path
178
180
  */
179
- convertPointsToSVGPath: function(points, minX, maxX, minY, maxY) {
181
+ convertPointsToSVGPath: function(points, minX, maxX, minY) {
180
182
  var path = [];
181
183
  var p1 = new fabric.Point(points[0].x - minX, points[0].y - minY);
182
184
  var p2 = new fabric.Point(points[1].x - minX, points[1].y - minY);
@@ -199,15 +201,23 @@
199
201
 
200
202
  /**
201
203
  * Creates fabric.Path object to add on canvas
202
- * @method createPath
203
204
  * @param {String} pathData Path data
204
205
  * @return {fabric.Path} path to add on canvas
205
206
  */
206
207
  createPath: function(pathData) {
207
208
  var path = new fabric.Path(pathData);
208
209
  path.fill = null;
209
- path.stroke = this.canvas.freeDrawingColor;
210
- path.strokeWidth = this.canvas.freeDrawingLineWidth;
210
+ path.stroke = this.color;
211
+ path.strokeWidth = this.width;
212
+ path.strokeLineCap = this.strokeLineCap;
213
+ path.strokeLineJoin = this.strokeLineJoin;
214
+ path.setShadow({
215
+ color: this.shadowColor || this.color,
216
+ blur: this.shadowBlur,
217
+ offsetX: this.shadowOffsetX,
218
+ offsetY: this.shadowOffsetY,
219
+ affectStroke: true
220
+ });
211
221
  return path;
212
222
  },
213
223
 
@@ -216,10 +226,8 @@
216
226
  * we use the points captured to create an new fabric path object
217
227
  * and add it to the fabric canvas.
218
228
  *
219
- * @method _finalizeAndAddPath
220
229
  */
221
230
  _finalizeAndAddPath: function() {
222
- this.canvas._isCurrentlyDrawing = false;
223
231
  var ctx = this.canvas.contextTop;
224
232
  ctx.closePath();
225
233
 
@@ -245,12 +253,12 @@
245
253
  this.canvas.add(path);
246
254
  path.setCoords();
247
255
 
248
- this.canvas.contextTop && this.canvas.clearContext(this.canvas.contextTop);
256
+ this.canvas.clearContext(this.canvas.contextTop);
257
+ this.removeShadowStyles();
249
258
  this.canvas.renderAll();
250
259
 
251
260
  // fire event 'path' created
252
261
  this.canvas.fire('path:created', { path: path });
253
262
  }
254
263
  });
255
-
256
- })(typeof exports !== 'undefined' ? exports : this);
264
+ })();