Merge pull request #4 from aha-app/issue-scale-lineWidth

Apply to scale to lineWidth.
This commit is contained in:
Chris Waters 2022-07-17 20:14:35 -07:00 committed by GitHub
commit 67d5dfd52e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 0 deletions

View File

@ -433,6 +433,9 @@ export default (function () {
//fill-opacity or stroke-opacity has already been set by stroke or fill. //fill-opacity or stroke-opacity has already been set by stroke or fill.
continue; 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 //otherwise only update attribute if right type, and not svg default
currentElement.setAttribute(attr, value); currentElement.setAttribute(attr, value);

View File

@ -11,6 +11,7 @@ import globalAlpha from './tests/globalalpha'
import gradient from './tests/gradient' import gradient from './tests/gradient'
import linecap from './tests/linecap' import linecap from './tests/linecap'
import linewidth from './tests/linewidth' import linewidth from './tests/linewidth'
import scaledLine from './tests/scaledLine'
import rgba from './tests/rgba' import rgba from './tests/rgba'
import rotate from './tests/rotate' import rotate from './tests/rotate'
import saveandrestore from './tests/saveandrestore' import saveandrestore from './tests/saveandrestore'
@ -34,6 +35,7 @@ const tests = [
gradient, gradient,
linecap, linecap,
linewidth, linewidth,
scaledLine,
rgba, rgba,
rotate, rotate,
saveandrestore, saveandrestore,

View File

@ -12,6 +12,7 @@ import globalAlpha from './tests/globalalpha'
import gradient from './tests/gradient' import gradient from './tests/gradient'
import linecap from './tests/linecap' import linecap from './tests/linecap'
import linewidth from './tests/linewidth' import linewidth from './tests/linewidth'
import scaledLine from './tests/scaledLine'
import rgba from './tests/rgba' import rgba from './tests/rgba'
import rotate from './tests/rotate' import rotate from './tests/rotate'
import saveandrestore from './tests/saveandrestore' import saveandrestore from './tests/saveandrestore'
@ -35,6 +36,7 @@ const tests = {
gradient, gradient,
linecap, linecap,
linewidth, linewidth,
scaledLine,
rgba, rgba,
rotate, rotate,
saveandrestore, saveandrestore,

10
test/tests/scaledLine.js Normal file
View File

@ -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();
}
};