From 323c648961a22dd3cb328c498e5df66c91999e4d Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 9 May 2015 09:42:16 +0200 Subject: [PATCH 1/2] Update text.class.js --- src/gradient.class.js | 11 ----------- src/shapes/text.class.js | 14 +++++++++++++- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/gradient.class.js b/src/gradient.class.js index 49a8a863..47f8a904 100644 --- a/src/gradient.class.js +++ b/src/gradient.class.js @@ -258,17 +258,6 @@ } } - if (object.type === 'text' || object.type === 'i-text') { - for (prop in coords) { - if (prop === 'x1' || prop === 'x2') { - coords[prop] -= object.width / 2; - } - else if (prop === 'y1' || prop === 'y2') { - coords[prop] -= object.height / 2; - } - } - } - if (this.type === 'linear') { gradient = ctx.createLinearGradient( coords.x1, coords.y1, coords.x2, coords.y2); diff --git a/src/shapes/text.class.js b/src/shapes/text.class.js index de3b20c4..53e01a2a 100644 --- a/src/shapes/text.class.js +++ b/src/shapes/text.class.js @@ -434,7 +434,19 @@ * @param {Number} top Top position of text */ _renderChars: function(method, ctx, chars, left, top) { + // remove Text word from method var + var shortM = method.slice(0, -4); + if (this[shortM].toLive) { + var offsetX = -this.width / 2 + this[shortM].offsetX || 0, + offsetY = -this.height / 2 + this[shortM].offsetY || 0; + ctx.save(); + ctx.translate(offsetX, offsetY); + left -= offsetX; + top -= offsetY; + } + console.log(ctx.strokeStyle); ctx[method](chars, left, top); + (offsetX || offsetY) && ctx.restore(); }, /** @@ -540,7 +552,7 @@ var lineHeights = 0; - if (!this.shadow.affectStroke) { + if (this.shadow && !this.shadow.affectStroke) { this._removeShadow(ctx); } From 5b429185f7506f8bf01e7e89b1a127262a44d9d1 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sun, 10 May 2015 18:51:31 +0200 Subject: [PATCH 2/2] Update text.class.js avoid ruining the stack on offsetX and offsetY equal to 0 --- src/shapes/text.class.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shapes/text.class.js b/src/shapes/text.class.js index 53e01a2a..6b77f490 100644 --- a/src/shapes/text.class.js +++ b/src/shapes/text.class.js @@ -446,7 +446,7 @@ } console.log(ctx.strokeStyle); ctx[method](chars, left, top); - (offsetX || offsetY) && ctx.restore(); + this[shortM].toLive && ctx.restore(); }, /**