diff --git a/context.js b/context.js index 4256edf..8b22aca 100644 --- a/context.js +++ b/context.js @@ -433,6 +433,9 @@ export default (function () { //fill-opacity or stroke-opacity has already been set by stroke or fill. continue; } + } else if (keys[i] === 'lineWidth') { + var scale = this.__getTransformScale(); + value = value * Math.max(scale.x, scale.y); } //otherwise only update attribute if right type, and not svg default currentElement.setAttribute(attr, value); diff --git a/test/index.js b/test/index.js index c7efca8..a00bf38 100644 --- a/test/index.js +++ b/test/index.js @@ -11,6 +11,7 @@ import globalAlpha from './tests/globalalpha' import gradient from './tests/gradient' import linecap from './tests/linecap' import linewidth from './tests/linewidth' +import scaledLine from './tests/scaledLine' import rgba from './tests/rgba' import rotate from './tests/rotate' import saveandrestore from './tests/saveandrestore' @@ -34,6 +35,7 @@ const tests = [ gradient, linecap, linewidth, + scaledLine, rgba, rotate, saveandrestore, diff --git a/test/rendering.test.js b/test/rendering.test.js index 62a03b1..4d7e0ef 100644 --- a/test/rendering.test.js +++ b/test/rendering.test.js @@ -12,6 +12,7 @@ import globalAlpha from './tests/globalalpha' import gradient from './tests/gradient' import linecap from './tests/linecap' import linewidth from './tests/linewidth' +import scaledLine from './tests/scaledLine' import rgba from './tests/rgba' import rotate from './tests/rotate' import saveandrestore from './tests/saveandrestore' @@ -35,6 +36,7 @@ const tests = { gradient, linecap, linewidth, + scaledLine, rgba, rotate, saveandrestore, diff --git a/test/tests/scaledLine.js b/test/tests/scaledLine.js new file mode 100644 index 0000000..0a910b4 --- /dev/null +++ b/test/tests/scaledLine.js @@ -0,0 +1,10 @@ +export default function scaledLine(ctx) { + ctx.scale(1.5, 1.5); + for (var i = 0; i < 10; i++){ + ctx.lineWidth = 1+i; + ctx.beginPath(); + ctx.moveTo(5+i*14,5); + ctx.lineTo(5+i*14,140); + ctx.stroke(); + } +}; \ No newline at end of file