diff --git a/src/core/text/Text.js b/src/core/text/Text.js index ac99698..d77e08c 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -676,10 +676,13 @@ var currentIteration; var stop; + var width = this.canvas.width / this.resolution; + var height = this.canvas.height / this.resolution; + if (style.fillGradientType === CONST.TEXT_GRADIENT.LINEAR_VERTICAL) { // start the gradient at the top center of the canvas, and end at the bottom middle of the canvas - gradient = this.context.createLinearGradient(this.canvas.width / 2, 0, this.canvas.width / 2, this.canvas.height); + gradient = this.context.createLinearGradient(width / 2, 0, width / 2, height); // we need to repeat the gradient so that each invididual line of text has the same vertical gradient effect // ['#FF0000', '#00FF00', '#0000FF'] over 2 lines would create stops at 0.125, 0.25, 0.375, 0.625, 0.75, 0.875 @@ -699,7 +702,7 @@ else { // start the gradient at the center left of the canvas, and end at the center right of the canvas - gradient = this.context.createLinearGradient(0, this.canvas.height / 2, this.canvas.width, this.canvas.height / 2); + gradient = this.context.createLinearGradient(0, height / 2, width, height / 2); // can just evenly space out the gradients in this case, as multiple lines makes no difference to an even left to right gradient totalIterations = style.fill.length + 1;