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
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @namespace fabric.Image.filters
3
+ * @memberOf fabric.Image
4
+ */
5
+ fabric.Image.filters = fabric.Image.filters || { };
6
+
7
+ /**
8
+ * GradientTransparency filter class
9
+ * @class fabric.Image.filters.GradientTransparency
10
+ * @memberOf fabric.Image.filters
11
+ */
12
+ fabric.Image.filters.GradientTransparency = fabric.util.createClass(/** @lends fabric.Image.filters.GradientTransparency.prototype */ {
13
+
14
+ /**
15
+ * Filter type
16
+ * @param {String} type
17
+ * @default
18
+ */
19
+ type: 'GradientTransparency',
20
+
21
+ /**
22
+ * Constructor
23
+ * @memberOf fabric.Image.filters.GradientTransparency
24
+ * @param {Object} [options] Options object
25
+ */
26
+ initialize: function(options) {
27
+ options = options || { };
28
+ this.threshold = options.threshold || 100;
29
+ },
30
+
31
+ /**
32
+ * Applies filter to canvas element
33
+ * @param {Object} canvasEl Canvas element to apply filter to
34
+ */
35
+ applyTo: function(canvasEl) {
36
+ var context = canvasEl.getContext('2d'),
37
+ imageData = context.getImageData(0, 0, canvasEl.width, canvasEl.height),
38
+ data = imageData.data,
39
+ threshold = this.threshold,
40
+ total = data.length;
41
+
42
+ for (var i = 0, len = data.length; i < len; i += 4) {
43
+ data[i + 3] = threshold + 255 * (total - i) / total;
44
+ }
45
+
46
+ context.putImageData(imageData, 0, 0);
47
+ },
48
+
49
+ /**
50
+ * Returns json representation of filter
51
+ * @return {String} json representation of filter
52
+ */
53
+ toJSON: function() {
54
+ return {
55
+ type: this.type,
56
+ threshold: this.threshold
57
+ };
58
+ }
59
+ });
60
+
61
+ /**
62
+ * Returns filter instance from an object representation
63
+ * @static
64
+ * @param {Object} object Object to create an instance from
65
+ * @return {fabric.Image.filters.GradientTransparency} Instance of fabric.Image.filters.GradientTransparency
66
+ */
67
+ fabric.Image.filters.GradientTransparency.fromObject = function(object) {
68
+ return new fabric.Image.filters.GradientTransparency(object);
69
+ };
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @namespace fabric.Image.filters
3
+ * @memberOf fabric.Image
4
+ */
5
+ fabric.Image.filters = fabric.Image.filters || { };
6
+
7
+ /**
8
+ * Grayscale image filter class
9
+ * @class fabric.Image.filters.Grayscale
10
+ * @memberOf fabric.Image.filters
11
+ */
12
+ fabric.Image.filters.Grayscale = fabric.util.createClass(/** @lends fabric.Image.filters.Grayscale.prototype */ {
13
+
14
+ /**
15
+ * Filter type
16
+ * @param {String} type
17
+ * @default
18
+ */
19
+ type: 'Grayscale',
20
+
21
+ /**
22
+ * Applies filter to canvas element
23
+ * @memberOf fabric.Image.filters.Grayscale.prototype
24
+ * @param {Object} canvasEl Canvas element to apply filter to
25
+ */
26
+ applyTo: function(canvasEl) {
27
+ var context = canvasEl.getContext('2d'),
28
+ imageData = context.getImageData(0, 0, canvasEl.width, canvasEl.height),
29
+ data = imageData.data,
30
+ len = imageData.width * imageData.height * 4,
31
+ index = 0,
32
+ average;
33
+
34
+ while (index < len) {
35
+ average = (data[index] + data[index + 1] + data[index + 2]) / 3;
36
+ data[index] = average;
37
+ data[index + 1] = average;
38
+ data[index + 2] = average;
39
+ index += 4;
40
+ }
41
+
42
+ context.putImageData(imageData, 0, 0);
43
+ },
44
+
45
+ /**
46
+ * Returns json representation of filter
47
+ * @return {Object} JSON representation of filter
48
+ */
49
+ toJSON: function() {
50
+ return { type: this.type };
51
+ }
52
+ });
53
+
54
+ /**
55
+ * Returns filter instance from an object representation
56
+ * @static
57
+ * @return {fabric.Image.filters.Grayscale} Instance of fabric.Image.filters.Grayscale
58
+ */
59
+ fabric.Image.filters.Grayscale.fromObject = function() {
60
+ return new fabric.Image.filters.Grayscale();
61
+ };
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @namespace fabric.Image.filters
3
+ * @memberOf fabric.Image
4
+ */
5
+ fabric.Image.filters = fabric.Image.filters || { };
6
+
7
+ /**
8
+ * Invert filter class
9
+ * @class fabric.Image.filters.Invert
10
+ * @memberOf fabric.Image.filters
11
+ */
12
+ fabric.Image.filters.Invert = fabric.util.createClass(/** @lends fabric.Image.filters.Invert.prototype */ {
13
+
14
+ /**
15
+ * Filter type
16
+ * @param {String} type
17
+ * @default
18
+ */
19
+ type: 'Invert',
20
+
21
+ /**
22
+ * Applies filter to canvas element
23
+ * @memberOf fabric.Image.filters.Invert.prototype
24
+ * @param {Object} canvasEl Canvas element to apply filter to
25
+ */
26
+ applyTo: function(canvasEl) {
27
+ var context = canvasEl.getContext('2d'),
28
+ imageData = context.getImageData(0, 0, canvasEl.width, canvasEl.height),
29
+ data = imageData.data,
30
+ iLen = data.length, i;
31
+
32
+ for (i = 0; i < iLen; i+=4) {
33
+ data[i] = 255 - data[i];
34
+ data[i + 1] = 255 - data[i + 1];
35
+ data[i + 2] = 255 - data[i + 2];
36
+ }
37
+
38
+ context.putImageData(imageData, 0, 0);
39
+ },
40
+
41
+ /**
42
+ * Returns json representation of filter
43
+ * @return {String} json representation of filter
44
+ */
45
+ toJSON: function() {
46
+ return { type: this.type };
47
+ }
48
+ });
49
+
50
+ /**
51
+ * Returns filter instance from an object representation
52
+ * @static
53
+ * @return {fabric.Image.filters.Invert} Instance of fabric.Image.filters.Invert
54
+ */
55
+ fabric.Image.filters.Invert.fromObject = function() {
56
+ return new fabric.Image.filters.Invert();
57
+ };
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @namespace fabric.Image.filters
3
+ * @memberOf fabric.Image
4
+ */
5
+ fabric.Image.filters = fabric.Image.filters || { };
6
+
7
+ /**
8
+ * Noise filter class
9
+ * @class fabric.Image.filters.Noise
10
+ * @memberOf fabric.Image.filters
11
+ */
12
+ fabric.Image.filters.Noise = fabric.util.createClass(/** @lends fabric.Image.filters.Noise.prototype */ {
13
+
14
+ /**
15
+ * Filter type
16
+ * @param {String} type
17
+ * @default
18
+ */
19
+ type: 'Noise',
20
+
21
+ /**
22
+ * Constructor
23
+ * @memberOf fabric.Image.filters.Noise.prototype
24
+ * @param {Object} [options] Options object
25
+ */
26
+ initialize: function(options) {
27
+ options = options || { };
28
+ this.noise = options.noise || 100;
29
+ },
30
+
31
+ /**
32
+ * Applies filter to canvas element
33
+ * @param {Object} canvasEl Canvas element to apply filter to
34
+ */
35
+ applyTo: function(canvasEl) {
36
+ var context = canvasEl.getContext('2d'),
37
+ imageData = context.getImageData(0, 0, canvasEl.width, canvasEl.height),
38
+ data = imageData.data,
39
+ noise = this.noise, rand;
40
+
41
+ for (var i = 0, len = data.length; i < len; i += 4) {
42
+
43
+ rand = (0.5 - Math.random()) * noise;
44
+
45
+ data[i] += rand;
46
+ data[i + 1] += rand;
47
+ data[i + 2] += rand;
48
+ }
49
+
50
+ context.putImageData(imageData, 0, 0);
51
+ },
52
+
53
+ /**
54
+ * Returns json representation of filter
55
+ * @return {String} json representation of filter
56
+ */
57
+ toJSON: function() {
58
+ return {
59
+ type: this.type,
60
+ noise: this.noise
61
+ };
62
+ }
63
+ });
64
+
65
+ /**
66
+ * Returns filter instance from an object representation
67
+ * @static
68
+ * @param {Object} object Object to create an instance from
69
+ * @return {fabric.Image.filters.Noise} Instance of fabric.Image.filters.Noise
70
+ */
71
+ fabric.Image.filters.Noise.fromObject = function(object) {
72
+ return new fabric.Image.filters.Noise(object);
73
+ };
@@ -0,0 +1,98 @@
1
+ /**
2
+ * @namespace fabric.Image.filters
3
+ * @memberOf fabric.Image
4
+ */
5
+ fabric.Image.filters = fabric.Image.filters || { };
6
+
7
+ /**
8
+ * Pixelate filter class
9
+ * @class fabric.Image.filters.Pixelate
10
+ * @memberOf fabric.Image.filters
11
+ */
12
+ fabric.Image.filters.Pixelate = fabric.util.createClass(/** @lends fabric.Image.filters.Pixelate.prototype */ {
13
+
14
+ /**
15
+ * Filter type
16
+ * @param {String} type
17
+ * @default
18
+ */
19
+ type: 'Pixelate',
20
+
21
+ /**
22
+ * Constructor
23
+ * @memberOf fabric.Image.filters.Pixelate.prototype
24
+ * @param {Object} [options] Options object
25
+ */
26
+ initialize: function(options) {
27
+ options = options || { };
28
+ this.blocksize = options.blocksize || 4;
29
+ },
30
+
31
+ /**
32
+ * Applies filter to canvas element
33
+ * @param {Object} canvasEl Canvas element to apply filter to
34
+ */
35
+ applyTo: function(canvasEl) {
36
+ var context = canvasEl.getContext('2d'),
37
+ imageData = context.getImageData(0, 0, canvasEl.width, canvasEl.height),
38
+ data = imageData.data,
39
+ iLen = imageData.height,
40
+ jLen = imageData.width,
41
+ index, i, j, r, g, b, a;
42
+
43
+ for (i = 0; i < iLen; i += this.blocksize) {
44
+ for (j = 0; j < jLen; j += this.blocksize) {
45
+
46
+ index = (i * 4) * jLen + (j * 4);
47
+
48
+ r = data[index];
49
+ g = data[index+1];
50
+ b = data[index+2];
51
+ a = data[index+3];
52
+
53
+ /*
54
+ blocksize: 4
55
+
56
+ [1,x,x,x,1]
57
+ [x,x,x,x,1]
58
+ [x,x,x,x,1]
59
+ [x,x,x,x,1]
60
+ [1,1,1,1,1]
61
+ */
62
+
63
+ for (var _i = i, _ilen = i + this.blocksize; _i < _ilen; _i++) {
64
+ for (var _j = j, _jlen = j + this.blocksize; _j < _jlen; _j++) {
65
+ index = (_i * 4) * jLen + (_j * 4);
66
+ data[index] = r;
67
+ data[index + 1] = g;
68
+ data[index + 2] = b;
69
+ data[index + 3] = a;
70
+ }
71
+ }
72
+ }
73
+ }
74
+
75
+ context.putImageData(imageData, 0, 0);
76
+ },
77
+
78
+ /**
79
+ * Returns json representation of filter
80
+ * @return {String} json representation of filter
81
+ */
82
+ toJSON: function() {
83
+ return {
84
+ type: this.type,
85
+ blocksize: this.blocksize
86
+ };
87
+ }
88
+ });
89
+
90
+ /**
91
+ * Returns filter instance from an object representation
92
+ * @static
93
+ * @param {Object} object Object to create an instance from
94
+ * @return {fabric.Image.filters.Pixelate} Instance of fabric.Image.filters.Pixelate
95
+ */
96
+ fabric.Image.filters.Pixelate.fromObject = function(object) {
97
+ return new fabric.Image.filters.Pixelate(object);
98
+ };
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @namespace fabric.Image.filters
3
+ * @memberOf fabric.Image
4
+ */
5
+ fabric.Image.filters = fabric.Image.filters || { };
6
+
7
+ /**
8
+ * Remove white filter class
9
+ * @class fabric.Image.filters.RemoveWhite
10
+ * @memberOf fabric.Image.filters
11
+ */
12
+ fabric.Image.filters.RemoveWhite = fabric.util.createClass(/** @lends fabric.Image.filters.RemoveWhite.prototype */ {
13
+
14
+ /**
15
+ * Filter type
16
+ * @param {String} type
17
+ * @default
18
+ */
19
+ type: 'RemoveWhite',
20
+
21
+ /**
22
+ * Constructor
23
+ * @memberOf fabric.Image.filters.RemoveWhite.prototype
24
+ * @param {Object} [options] Options object
25
+ */
26
+ initialize: function(options) {
27
+ options = options || { };
28
+ this.threshold = options.threshold || 30;
29
+ this.distance = options.distance || 20;
30
+ },
31
+
32
+ /**
33
+ * Applies filter to canvas element
34
+ * @param {Object} canvasEl Canvas element to apply filter to
35
+ */
36
+ applyTo: function(canvasEl) {
37
+ var context = canvasEl.getContext('2d'),
38
+ imageData = context.getImageData(0, 0, canvasEl.width, canvasEl.height),
39
+ data = imageData.data,
40
+ threshold = this.threshold,
41
+ distance = this.distance,
42
+ limit = 255 - threshold,
43
+ abs = Math.abs,
44
+ r, g, b;
45
+
46
+ for (var i = 0, len = data.length; i < len; i += 4) {
47
+ r = data[i];
48
+ g = data[i+1];
49
+ b = data[i+2];
50
+
51
+ if (r > limit &&
52
+ g > limit &&
53
+ b > limit &&
54
+ abs(r-g) < distance &&
55
+ abs(r-b) < distance &&
56
+ abs(g-b) < distance
57
+ ) {
58
+ data[i+3] = 1;
59
+ }
60
+ }
61
+
62
+ context.putImageData(imageData, 0, 0);
63
+ },
64
+
65
+ /**
66
+ * Returns json representation of filter
67
+ * @return {Object} JSON representation of filter
68
+ */
69
+ toJSON: function() {
70
+ return {
71
+ type: this.type,
72
+ threshold: this.threshold,
73
+ distance: this.distance
74
+ };
75
+ }
76
+ });
77
+
78
+ /**
79
+ * Returns filter instance from an object representation
80
+ * @static
81
+ * @param {Object} object Object to create an instance from
82
+ * @return {fabric.Image.filters.RemoveWhite} Instance of fabric.Image.filters.RemoveWhite
83
+ */
84
+ fabric.Image.filters.RemoveWhite.fromObject = function(object) {
85
+ return new fabric.Image.filters.RemoveWhite(object);
86
+ };