fabric-rails 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 0.0.3 (21 August 2012)
2
+
3
+ - fabric.js version 0.9.0
4
+
5
+ ## 0.0.2 (17 August 2012)
6
+
7
+ - fabric.js version 0.8.53
8
+
1
9
  ## 0.0.1 (16 August 2012)
2
10
 
3
11
  - Started project, fabric.js version 0.8.52
data/Gemfile.lock CHANGED
@@ -1,36 +1,36 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fabric-rails (0.0.1)
4
+ fabric-rails (0.0.3)
5
5
  railties (>= 3.2.0, < 5.0)
6
6
  thor (~> 0.14)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- actionpack (3.2.8)
12
- activemodel (= 3.2.8)
13
- activesupport (= 3.2.8)
11
+ actionpack (3.2.1)
12
+ activemodel (= 3.2.1)
13
+ activesupport (= 3.2.1)
14
14
  builder (~> 3.0.0)
15
15
  erubis (~> 2.7.0)
16
- journey (~> 1.0.4)
16
+ journey (~> 1.0.1)
17
17
  rack (~> 1.4.0)
18
- rack-cache (~> 1.2)
18
+ rack-cache (~> 1.1)
19
19
  rack-test (~> 0.6.1)
20
- sprockets (~> 2.1.3)
21
- activemodel (3.2.8)
22
- activesupport (= 3.2.8)
20
+ sprockets (~> 2.1.2)
21
+ activemodel (3.2.1)
22
+ activesupport (= 3.2.1)
23
23
  builder (~> 3.0.0)
24
- activesupport (3.2.8)
24
+ activesupport (3.2.1)
25
25
  i18n (~> 0.6)
26
26
  multi_json (~> 1.0)
27
27
  builder (3.0.0)
28
28
  erubis (2.7.0)
29
29
  hike (1.2.1)
30
30
  i18n (0.6.0)
31
- journey (1.0.4)
32
- json (1.7.4)
33
- multi_json (1.3.6)
31
+ journey (1.0.3)
32
+ json (1.6.5)
33
+ multi_json (1.1.0)
34
34
  rack (1.4.1)
35
35
  rack-cache (1.2)
36
36
  rack (>= 0.4)
@@ -38,21 +38,21 @@ GEM
38
38
  rack
39
39
  rack-test (0.6.1)
40
40
  rack (>= 1.0)
41
- railties (3.2.8)
42
- actionpack (= 3.2.8)
43
- activesupport (= 3.2.8)
41
+ railties (3.2.1)
42
+ actionpack (= 3.2.1)
43
+ activesupport (= 3.2.1)
44
44
  rack-ssl (~> 1.3.2)
45
45
  rake (>= 0.8.7)
46
46
  rdoc (~> 3.4)
47
- thor (>= 0.14.6, < 2.0)
47
+ thor (~> 0.14.6)
48
48
  rake (0.9.2.2)
49
49
  rdoc (3.12)
50
50
  json (~> 1.4)
51
- sprockets (2.1.3)
51
+ sprockets (2.1.2)
52
52
  hike (~> 1.2)
53
53
  rack (~> 1.0)
54
54
  tilt (~> 1.1, != 1.3.0)
55
- thor (0.15.4)
55
+ thor (0.14.6)
56
56
  tilt (1.3.3)
57
57
 
58
58
  PLATFORMS
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  This gem provides:
6
6
 
7
- * fabric.js 0.8.52
7
+ * fabric.js 0.9.0
8
8
 
9
9
  ## Installation
10
10
 
@@ -1,6 +1,6 @@
1
1
  module Fabric
2
2
  module Rails
3
- VERSION = "0.0.1"
4
- FABRIC_VERSION = "0.8.52"
3
+ VERSION = "0.0.3"
4
+ FABRIC_VERSION = "0.9.0"
5
5
  end
6
6
  end
@@ -1,7 +1,7 @@
1
1
  /* build: `node build.js modules=ALL` */
2
2
  /*! Fabric.js Copyright 2008-2012, Printio (Juriy Zaytsev, Maxim Chernyak) */
3
3
 
4
- var fabric = fabric || { version: "0.8.52" };
4
+ var fabric = fabric || { version: "0.9.0" };
5
5
 
6
6
  if (typeof exports != 'undefined') {
7
7
  exports.fabric = fabric;
@@ -2932,28 +2932,28 @@ fabric.util.string = {
2932
2932
  * @param {Function} callback Callback to execute when script is finished loading
2933
2933
  */
2934
2934
  function getScript(url, callback) {
2935
- var headEl = fabric.document.getElementsByTagName("head")[0],
2936
- scriptEl = fabric.document.createElement('script'),
2937
- loading = true;
2938
-
2939
- scriptEl.type = 'text/javascript';
2940
- scriptEl.setAttribute('runat', 'server');
2941
-
2942
- /** @ignore */
2943
- scriptEl.onload = /** @ignore */ scriptEl.onreadystatechange = function(e) {
2944
- if (loading) {
2945
- if (typeof this.readyState == 'string' &&
2946
- this.readyState !== 'loaded' &&
2947
- this.readyState !== 'complete') return;
2948
- loading = false;
2949
- callback(e || fabric.window.event);
2950
- scriptEl = scriptEl.onload = scriptEl.onreadystatechange = null;
2951
- }
2952
- };
2953
- scriptEl.src = url;
2954
- headEl.appendChild(scriptEl);
2955
- // causes issue in Opera
2956
- // headEl.removeChild(scriptEl);
2935
+ var headEl = fabric.document.getElementsByTagName("head")[0],
2936
+ scriptEl = fabric.document.createElement('script'),
2937
+ loading = true;
2938
+
2939
+ scriptEl.type = 'text/javascript';
2940
+ scriptEl.setAttribute('runat', 'server');
2941
+
2942
+ /** @ignore */
2943
+ scriptEl.onload = /** @ignore */ scriptEl.onreadystatechange = function(e) {
2944
+ if (loading) {
2945
+ if (typeof this.readyState == 'string' &&
2946
+ this.readyState !== 'loaded' &&
2947
+ this.readyState !== 'complete') return;
2948
+ loading = false;
2949
+ callback(e || fabric.window.event);
2950
+ scriptEl = scriptEl.onload = scriptEl.onreadystatechange = null;
2951
+ }
2952
+ };
2953
+ scriptEl.src = url;
2954
+ headEl.appendChild(scriptEl);
2955
+ // causes issue in Opera
2956
+ // headEl.removeChild(scriptEl);
2957
2957
  }
2958
2958
 
2959
2959
  fabric.util.getScript = getScript;
@@ -3644,11 +3644,6 @@ fabric.util.string = {
3644
3644
  };
3645
3645
 
3646
3646
  function resolveGradients(instances) {
3647
- var activeInstance = fabric.Canvas.activeInstance,
3648
- ctx = activeInstance ? activeInstance.getContext() : null;
3649
-
3650
- if (!ctx) return;
3651
-
3652
3647
  for (var i = instances.length; i--; ) {
3653
3648
  var instanceFillValue = instances[i].get('fill');
3654
3649
 
@@ -3658,7 +3653,7 @@ fabric.util.string = {
3658
3653
 
3659
3654
  if (fabric.gradientDefs[gradientId]) {
3660
3655
  instances[i].set('fill',
3661
- fabric.Gradient.fromElement(fabric.gradientDefs[gradientId], ctx, instances[i]));
3656
+ fabric.Gradient.fromElement(fabric.gradientDefs[gradientId], instances[i]));
3662
3657
  }
3663
3658
  }
3664
3659
  }
@@ -3672,8 +3667,9 @@ fabric.util.string = {
3672
3667
  * @param {Array} elements Array of elements to parse
3673
3668
  * @param {Function} callback Being passed an array of fabric instances (transformed from SVG elements)
3674
3669
  * @param {Object} options Options object
3670
+ * @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created.
3675
3671
  */
3676
- function parseElements(elements, callback, options) {
3672
+ function parseElements(elements, callback, options, reviver) {
3677
3673
  var instances = Array(elements.length), i = elements.length;
3678
3674
 
3679
3675
  function checkIfDone() {
@@ -3692,15 +3688,18 @@ fabric.util.string = {
3692
3688
  if (klass && klass.fromElement) {
3693
3689
  try {
3694
3690
  if (klass.async) {
3695
- klass.fromElement(el, (function(index) {
3691
+ klass.fromElement(el, (function(index, el) {
3696
3692
  return function(obj) {
3693
+ reviver && reviver(el, obj);
3697
3694
  instances.splice(index, 0, obj);
3698
3695
  checkIfDone();
3699
3696
  };
3700
3697
  })(index), options);
3701
3698
  }
3702
3699
  else {
3703
- instances.splice(index, 0, klass.fromElement(el, options));
3700
+ var obj = klass.fromElement(el, options);
3701
+ reviver && reviver(el, obj);
3702
+ instances.splice(index, 0, obj);
3704
3703
  checkIfDone();
3705
3704
  }
3706
3705
  }
@@ -3790,6 +3789,7 @@ fabric.util.string = {
3790
3789
  * @method parseSVGDocument
3791
3790
  * @param {SVGDocument} doc SVG document to parse
3792
3791
  * @param {Function} callback Callback to call when parsing is finished; It's being passed an array of elements (parsed from a document).
3792
+ * @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created.
3793
3793
  */
3794
3794
  fabric.parseSVGDocument = (function() {
3795
3795
 
@@ -3819,7 +3819,7 @@ fabric.util.string = {
3819
3819
  return false;
3820
3820
  }
3821
3821
 
3822
- return function(doc, callback) {
3822
+ return function(doc, callback, reviver) {
3823
3823
  if (!doc) return;
3824
3824
 
3825
3825
  var startTime = new Date(),
@@ -3877,7 +3877,7 @@ fabric.util.string = {
3877
3877
  if (callback) {
3878
3878
  callback(instances, options);
3879
3879
  }
3880
- }, clone(options));
3880
+ }, clone(options), reviver);
3881
3881
  };
3882
3882
  })();
3883
3883
 
@@ -3921,8 +3921,9 @@ fabric.util.string = {
3921
3921
  * @method loadSVGFromURL
3922
3922
  * @param {String} url
3923
3923
  * @param {Function} callback
3924
+ * @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created.
3924
3925
  */
3925
- function loadSVGFromURL(url, callback) {
3926
+ function loadSVGFromURL(url, callback, reviver) {
3926
3927
 
3927
3928
  url = url.replace(/^\n\s*/, '').trim();
3928
3929
 
@@ -3958,7 +3959,7 @@ fabric.util.string = {
3958
3959
  options: options
3959
3960
  });
3960
3961
  callback(results, options);
3961
- });
3962
+ }, reviver);
3962
3963
  }
3963
3964
  }
3964
3965
 
@@ -3982,8 +3983,9 @@ fabric.util.string = {
3982
3983
  * @method loadSVGFromString
3983
3984
  * @param {String} string
3984
3985
  * @param {Function} callback
3986
+ * @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created.
3985
3987
  */
3986
- function loadSVGFromString(string, callback) {
3988
+ function loadSVGFromString(string, callback, reviver) {
3987
3989
  string = string.trim();
3988
3990
  var doc;
3989
3991
  if (typeof DOMParser !== 'undefined') {
@@ -4001,7 +4003,7 @@ fabric.util.string = {
4001
4003
 
4002
4004
  fabric.parseSVGDocument(doc.documentElement, function (results, options) {
4003
4005
  callback(results, options);
4004
- });
4006
+ }, reviver);
4005
4007
  }
4006
4008
 
4007
4009
  function createSVGFontFacesMarkup(objects) {
@@ -4074,38 +4076,55 @@ fabric.util.string = {
4074
4076
  }
4075
4077
  }
4076
4078
 
4077
- /** @namespace */
4079
+ /**
4080
+ * @class Object
4081
+ * @memberOf fabric
4082
+ */
4083
+ fabric.Gradient = fabric.util.createClass(/** @scope fabric.Gradient.prototype */ {
4078
4084
 
4079
- fabric.Gradient = {
4085
+ initialize: function(options) {
4080
4086
 
4081
- /**
4082
- * @method create
4083
- * @static
4084
- */
4085
- create: function(ctx, options) {
4086
4087
  options || (options = { });
4087
4088
 
4088
- var x1 = options.x1 || 0,
4089
- y1 = options.y1 || 0,
4090
- x2 = options.x2 || ctx.canvas.width,
4091
- y2 = options.y2 || 0,
4092
- colorStops = options.colorStops;
4089
+ this.x1 = options.x1 || 0;
4090
+ this.y1 = options.y1 || 0;
4091
+ this.x2 = options.x2 || 0;
4092
+ this.y2 = options.y2 || 0;
4093
+
4094
+ this.colorStops = options.colorStops;
4095
+ },
4096
+
4097
+ toObject: function() {
4098
+ return {
4099
+ x1: this.x1,
4100
+ x2: this.x2,
4101
+ y1: this.y1,
4102
+ y2: this.y2,
4103
+ colorStops: this.colorStops
4104
+ };
4105
+ },
4093
4106
 
4094
- var gradient = ctx.createLinearGradient(x1, y1, x2, y2);
4107
+ toLiveGradient: function(ctx) {
4108
+ var gradient = ctx.createLinearGradient(
4109
+ this.x1, this.y1, this.x2 || ctx.canvas.width, this.y2);
4095
4110
 
4096
- for (var position in colorStops) {
4097
- var colorValue = colorStops[position];
4111
+ for (var position in this.colorStops) {
4112
+ var colorValue = this.colorStops[position];
4098
4113
  gradient.addColorStop(parseFloat(position), colorValue);
4099
4114
  }
4115
+
4100
4116
  return gradient;
4101
- },
4117
+ }
4118
+ });
4119
+
4120
+ fabric.util.object.extend(fabric.Gradient, {
4102
4121
 
4103
4122
  /**
4104
4123
  * @method fromElement
4105
4124
  * @static
4106
4125
  * @see http://www.w3.org/TR/SVG/pservers.html#LinearGradientElement
4107
4126
  */
4108
- fromElement: function(el, ctx, instance) {
4127
+ fromElement: function(el, instance) {
4109
4128
 
4110
4129
  /**
4111
4130
  * @example:
@@ -4147,7 +4166,7 @@ fabric.util.string = {
4147
4166
 
4148
4167
  _convertPercentUnitsToValues(instance, coords);
4149
4168
 
4150
- return fabric.Gradient.create(ctx, {
4169
+ return new fabric.Gradient({
4151
4170
  x1: coords.x1,
4152
4171
  y1: coords.y1,
4153
4172
  x2: coords.x2,
@@ -4160,22 +4179,12 @@ fabric.util.string = {
4160
4179
  * @method forObject
4161
4180
  * @static
4162
4181
  */
4163
- forObject: function(obj, ctx, options) {
4182
+ forObject: function(obj, options) {
4164
4183
  options || (options = { });
4165
-
4166
4184
  _convertPercentUnitsToValues(obj, options);
4167
-
4168
- var gradient = fabric.Gradient.create(ctx, {
4169
- x1: options.x1,
4170
- y1: options.y1,
4171
- x2: options.x2,
4172
- y2: options.y2,
4173
- colorStops: options.colorStops
4174
- });
4175
-
4176
- return gradient;
4185
+ return new fabric.Gradient(options);
4177
4186
  }
4178
- };
4187
+ });
4179
4188
 
4180
4189
  function _convertPercentUnitsToValues(object, options) {
4181
4190
  for (var prop in options) {
@@ -5216,15 +5225,24 @@ fabric.util.string = {
5216
5225
  add: function () {
5217
5226
  this._objects.push.apply(this._objects, arguments);
5218
5227
  for (var i = arguments.length; i--; ) {
5219
- this.stateful && arguments[i].setupState();
5220
- arguments[i].setCoords();
5221
- this.fire('object:added', { target: arguments[i] });
5222
- arguments[i].fire('added');
5228
+ this._initObject(arguments[i]);
5223
5229
  }
5224
5230
  this.renderOnAddition && this.renderAll();
5225
5231
  return this;
5226
5232
  },
5227
5233
 
5234
+ /**
5235
+ * @private
5236
+ * @method _initObject
5237
+ */
5238
+ _initObject: function(obj) {
5239
+ this.stateful && obj.setupState();
5240
+ obj.setCoords();
5241
+ obj.canvas = this;
5242
+ this.fire('object:added', { target: obj });
5243
+ obj.fire('added');
5244
+ },
5245
+
5228
5246
  /**
5229
5247
  * Inserts an object to canvas at specified index and renders canvas.
5230
5248
  * An object should be an instance of (or inherit from) fabric.Object
@@ -5241,12 +5259,7 @@ fabric.util.string = {
5241
5259
  else {
5242
5260
  this._objects.splice(index, 0, object);
5243
5261
  }
5244
- this.stateful && object.setupState();
5245
- object.setCoords();
5246
-
5247
- this.fire('object:added', { target: object });
5248
- object.fire('added');
5249
-
5262
+ this._initObject(object);
5250
5263
  this.renderOnAddition && this.renderAll();
5251
5264
  return this;
5252
5265
  },
@@ -5410,11 +5423,12 @@ fabric.util.string = {
5410
5423
  * Exports canvas element to a dataurl image.
5411
5424
  * @method toDataURL
5412
5425
  * @param {String} format the format of the output image. Either "jpeg" or "png".
5426
+ * @param {Number} quality quality level (0..1)
5413
5427
  * @return {String}
5414
5428
  */
5415
- toDataURL: function (format) {
5429
+ toDataURL: function (format, quality) {
5416
5430
  this.renderAll(true);
5417
- var data = (this.upperCanvasEl || this.lowerCanvasEl).toDataURL('image/' + format);
5431
+ var data = (this.upperCanvasEl || this.lowerCanvasEl).toDataURL('image/' + format, quality);
5418
5432
  this.renderAll();
5419
5433
  return data;
5420
5434
  },
@@ -5424,9 +5438,10 @@ fabric.util.string = {
5424
5438
  * @method toDataURLWithMultiplier
5425
5439
  * @param {String} format (png|jpeg)
5426
5440
  * @param {Number} multiplier
5441
+ * @param {Number} quality (0..1)
5427
5442
  * @return {String}
5428
5443
  */
5429
- toDataURLWithMultiplier: function (format, multiplier) {
5444
+ toDataURLWithMultiplier: function (format, multiplier, quality) {
5430
5445
 
5431
5446
  var origWidth = this.getWidth(),
5432
5447
  origHeight = this.getHeight(),
@@ -5453,7 +5468,7 @@ fabric.util.string = {
5453
5468
 
5454
5469
  this.renderAll(true);
5455
5470
 
5456
- var dataURL = this.toDataURL(format);
5471
+ var dataURL = this.toDataURL(format, quality);
5457
5472
 
5458
5473
  this.contextTop.scale(1 / multiplier, 1 / multiplier);
5459
5474
  this.setWidth(origWidth).setHeight(origHeight);
@@ -6909,7 +6924,7 @@ fabric.util.string = {
6909
6924
 
6910
6925
  /**
6911
6926
  * Returns context of canvas where object selection is drawn
6912
- * @method getContext
6927
+ * @method getSelectionContext
6913
6928
  * @return {CanvasRenderingContext2D}
6914
6929
  */
6915
6930
  getSelectionContext: function() {
@@ -6918,7 +6933,7 @@ fabric.util.string = {
6918
6933
 
6919
6934
  /**
6920
6935
  * Returns &lt;canvas> element on which object selection is drawn
6921
- * @method getElement
6936
+ * @method getSelectionElement
6922
6937
  * @return {HTMLCanvasElement}
6923
6938
  */
6924
6939
  getSelectionElement: function () {
@@ -7576,7 +7591,19 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
7576
7591
  * @param {Object} [options] Options object
7577
7592
  */
7578
7593
  initialize: function(options) {
7579
- options && this.setOptions(options);
7594
+ if (options) {
7595
+ this.setOptions(options);
7596
+ this._initGradient(options);
7597
+ }
7598
+ },
7599
+
7600
+ /**
7601
+ * @method initGradient
7602
+ */
7603
+ _initGradient: function(options) {
7604
+ if (options.fill && typeof options.fill == 'object' && !(options.fill instanceof fabric.Gradient)) {
7605
+ this.set('fill', new fabric.Gradient(options.fill));
7606
+ }
7580
7607
  },
7581
7608
 
7582
7609
  /**
@@ -7620,7 +7647,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
7620
7647
  top: toFixed(this.top, this.NUM_FRACTION_DIGITS),
7621
7648
  width: toFixed(this.width, this.NUM_FRACTION_DIGITS),
7622
7649
  height: toFixed(this.height, this.NUM_FRACTION_DIGITS),
7623
- fill: this.fill,
7650
+ fill: (this.fill && this.fill.toObject) ? this.fill.toObject() : this.fill,
7624
7651
  overlayFill: this.overlayFill,
7625
7652
  stroke: this.stroke,
7626
7653
  strokeWidth: this.strokeWidth,
@@ -7833,7 +7860,9 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
7833
7860
  ctx.fillStyle = this.overlayFill;
7834
7861
  }
7835
7862
  else if (this.fill) {
7836
- ctx.fillStyle = this.fill;
7863
+ ctx.fillStyle = this.fill.toLiveGradient
7864
+ ? this.fill.toLiveGradient(ctx)
7865
+ : this.fill;
7837
7866
  }
7838
7867
 
7839
7868
  if (this.group && this.type === 'rect') {
@@ -8811,8 +8840,8 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
8811
8840
  return this.toObject();
8812
8841
  },
8813
8842
 
8814
- setGradientFill: function(ctx, options) {
8815
- this.set('fill', fabric.Gradient.forObject(this, ctx, options));
8843
+ setGradientFill: function(options) {
8844
+ this.set('fill', fabric.Gradient.forObject(this, options));
8816
8845
  },
8817
8846
 
8818
8847
  animate: function(property, to, options) {
@@ -8843,6 +8872,91 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
8843
8872
  options.onComplete && options.onComplete();
8844
8873
  }
8845
8874
  });
8875
+ },
8876
+
8877
+ /**
8878
+ * Centers object horizontally on canvas to which it was added last
8879
+ * @method centerH
8880
+ * @return {fabric.Object} thisArg
8881
+ */
8882
+ centerH: function () {
8883
+ this.canvas.centerObjectH(this);
8884
+ return this;
8885
+ },
8886
+
8887
+ /**
8888
+ * Centers object vertically on canvas to which it was added last
8889
+ * @method centerV
8890
+ * @return {fabric.Object} thisArg
8891
+ * @chainable
8892
+ */
8893
+ centerV: function () {
8894
+ this.canvas.centerObjectV(this);
8895
+ return this;
8896
+ },
8897
+
8898
+ /**
8899
+ * Centers object vertically and horizontally on canvas to which is was added last
8900
+ * @method center
8901
+ * @return {fabric.Object} thisArg
8902
+ * @chainable
8903
+ */
8904
+ center: function () {
8905
+ return this.centerH().centerV();
8906
+ },
8907
+
8908
+ /**
8909
+ * Removes object from canvas to which it was added last
8910
+ * @method remove
8911
+ * @return {fabric.Object} thisArg
8912
+ * @chainable
8913
+ */
8914
+ remove: function() {
8915
+ return this.canvas.remove(this);
8916
+ },
8917
+
8918
+ /**
8919
+ * Moves an object to the bottom of the stack of drawn objects
8920
+ * @method sendToBack
8921
+ * @return {fabric.Object} thisArg
8922
+ * @chainable
8923
+ */
8924
+ sendToBack: function() {
8925
+ this.canvas.sendToBack(this);
8926
+ return this;
8927
+ },
8928
+
8929
+ /**
8930
+ * Moves an object to the top of the stack of drawn objects
8931
+ * @method bringToFront
8932
+ * @return {fabric.Object} thisArg
8933
+ * @chainable
8934
+ */
8935
+ bringToFront: function() {
8936
+ this.canvas.bringToFront(this);
8937
+ return this;
8938
+ },
8939
+
8940
+ /**
8941
+ * Moves an object one level down in stack of drawn objects
8942
+ * @method sendBackwards
8943
+ * @return {fabric.Object} thisArg
8944
+ * @chainable
8945
+ */
8946
+ sendBackwards: function() {
8947
+ this.canvas.sendBackwards(this);
8948
+ return this;
8949
+ },
8950
+
8951
+ /**
8952
+ * Moves an object one level up in stack of drawn objects
8953
+ * @method bringForward
8954
+ * @return {fabric.Object} thisArg
8955
+ * @chainable
8956
+ */
8957
+ bringForward: function() {
8958
+ this.canvas.bringForward(this);
8959
+ return this;
8846
8960
  }
8847
8961
  });
8848
8962
 
@@ -10251,12 +10365,15 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
10251
10365
  */
10252
10366
  _render: function(ctx) {
10253
10367
  var current, // current instruction
10368
+ previous = null,
10254
10369
  x = 0, // current x
10255
10370
  y = 0, // current y
10256
10371
  controlX = 0, // current control point x
10257
10372
  controlY = 0, // current control point y
10258
10373
  tempX,
10259
10374
  tempY,
10375
+ tempControlX,
10376
+ tempControlY,
10260
10377
  l = -(this.width / 2),
10261
10378
  t = -(this.height / 2);
10262
10379
 
@@ -10425,13 +10542,31 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
10425
10542
  break;
10426
10543
 
10427
10544
  case 't': // shorthand quadraticCurveTo, relative
10545
+
10428
10546
  // transform to absolute x,y
10429
10547
  tempX = x + current[1];
10430
10548
  tempY = y + current[2];
10549
+
10431
10550
 
10432
- // calculate reflection of previous control points
10433
- controlX = 2 * x - controlX;
10434
- controlY = 2 * y - controlY;
10551
+ if (previous[0].match(/[QqTt]/) === null) {
10552
+ // If there is no previous command or if the previous command was not a Q, q, T or t,
10553
+ // assume the control point is coincident with the current point
10554
+ controlX = x;
10555
+ controlY = y;
10556
+ }
10557
+ else if (previous[0] === 't') {
10558
+ // calculate reflection of previous control points for t
10559
+ controlX = 2 * x - tempControlX;
10560
+ controlY = 2 * y - tempControlY;
10561
+ }
10562
+ else if (previous[0] === 'q') {
10563
+ // calculate reflection of previous control points for q
10564
+ controlX = 2 * x - controlX;
10565
+ controlY = 2 * y - controlY;
10566
+ }
10567
+
10568
+ tempControlX = controlX;
10569
+ tempControlY = controlY;
10435
10570
 
10436
10571
  ctx.quadraticCurveTo(
10437
10572
  controlX + l,
@@ -10497,6 +10632,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
10497
10632
  ctx.closePath();
10498
10633
  break;
10499
10634
  }
10635
+ previous = current
10500
10636
  }
10501
10637
  },
10502
10638
 
@@ -12532,16 +12668,16 @@ fabric.Image.filters.Tint = fabric.util.createClass( /** @scope fabric.Image.fil
12532
12668
  iLen = data.length, i,
12533
12669
  r, g, b, a;
12534
12670
 
12535
- var rgb = parseInt(this.color).toString(16);
12536
- var cr = parseInt('0x'+rgb.substr(0, 2));
12537
- var cg = parseInt('0x'+rgb.substr(2, 2));
12538
- var cb = parseInt('0x'+rgb.substr(4, 2));
12539
-
12671
+ var rgb = parseInt(this.color).toString(16);
12672
+ var cr = parseInt('0x'+rgb.substr(0, 2));
12673
+ var cg = parseInt('0x'+rgb.substr(2, 2));
12674
+ var cb = parseInt('0x'+rgb.substr(4, 2));
12675
+
12540
12676
  for (i = 0; i < iLen; i+=4) {
12541
12677
 
12542
12678
  a = data[i+3];
12543
12679
 
12544
- if (a > 0){
12680
+ if (a > 0){
12545
12681
  data[i] = cr;
12546
12682
  data[i+1] = cg;
12547
12683
  data[i+2] = cb;
@@ -13046,7 +13182,7 @@ fabric.Image.filters.Tint.fromObject = function(object) {
13046
13182
  this.fontStyle,
13047
13183
  this.fontWeight,
13048
13184
  this.fontSize + 'px',
13049
- this.fontFamily
13185
+ (fabric.isLikelyNode ? ('"' + this.fontFamily + '"') : this.fontFamily)
13050
13186
  ].join(' ');
13051
13187
  },
13052
13188
 
@@ -13496,4 +13632,4 @@ fabric.Image.filters.Tint.fromObject = function(object) {
13496
13632
  fabric.Canvas.prototype.setHeight = fabric.StaticCanvas.prototype.setHeight;
13497
13633
  }
13498
13634
 
13499
- })();
13635
+ })();
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fabric-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-16 00:00:00.000000000 Z
12
+ date: 2012-08-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
16
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &70210922100120 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -24,18 +24,10 @@ dependencies:
24
24
  version: '5.0'
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: 3.2.0
33
- - - <
34
- - !ruby/object:Gem::Version
35
- version: '5.0'
27
+ version_requirements: *70210922100120
36
28
  - !ruby/object:Gem::Dependency
37
29
  name: thor
38
- requirement: !ruby/object:Gem::Requirement
30
+ requirement: &70210922133420 !ruby/object:Gem::Requirement
39
31
  none: false
40
32
  requirements:
41
33
  - - ~>
@@ -43,12 +35,7 @@ dependencies:
43
35
  version: '0.14'
44
36
  type: :runtime
45
37
  prerelease: false
46
- version_requirements: !ruby/object:Gem::Requirement
47
- none: false
48
- requirements:
49
- - - ~>
50
- - !ruby/object:Gem::Version
51
- version: '0.14'
38
+ version_requirements: *70210922133420
52
39
  description: This gem provides fabric.js for your Rails 3 application via the asset
53
40
  pipeline.
54
41
  email:
@@ -82,9 +69,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
69
  - - ! '>='
83
70
  - !ruby/object:Gem::Version
84
71
  version: '0'
85
- segments:
86
- - 0
87
- hash: -4152026692481514148
88
72
  required_rubygems_version: !ruby/object:Gem::Requirement
89
73
  none: false
90
74
  requirements:
@@ -93,8 +77,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
77
  version: 1.3.6
94
78
  requirements: []
95
79
  rubyforge_project: fabric-rails
96
- rubygems_version: 1.8.24
80
+ rubygems_version: 1.8.15
97
81
  signing_key:
98
82
  specification_version: 3
99
83
  summary: Easily use fabric.js with Rails 3
100
84
  test_files: []
85
+ has_rdoc: