Add hack to prevent incorrectly scaled stroke
This commit is contained in:
parent
a891b0ad58
commit
2e5bd80cdb
@ -779,6 +779,8 @@ export default (function () {
|
||||
var pathElement = this.__createPathElement();
|
||||
this.__applyStyleToElement(pathElement, action);
|
||||
pathElement.setAttribute("paint-order", "fill stroke markers");
|
||||
// This is a hack to replicate the behavior of Fabric.
|
||||
pathElement.setAttribute("vector-effect", "non-scaling-stroke");
|
||||
pathElement.setAttribute("d", path.__pathString);
|
||||
if (path2d) {
|
||||
this.__applyTransformation(pathElement);
|
||||
@ -790,6 +792,7 @@ export default (function () {
|
||||
var pathElement = this.__createPathElement();
|
||||
this.__applyStyleToElement(pathElement, action);
|
||||
pathElement.setAttribute("paint-order", "fill stroke markers");
|
||||
pathElement.setAttribute("vector-effect", "non-scaling-stroke");
|
||||
pathElement.setAttribute("d", subPath.path.__pathString);
|
||||
if (subPath.transform) {
|
||||
this.__applyTransformation(pathElement, this.getTransform().multiply(subPath.transform));
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@aha-app/svgcanvas",
|
||||
"version": "2.5.0-a14",
|
||||
"version": "2.5.0-a15",
|
||||
"description": "svgcanvas",
|
||||
"main": "dist/svgcanvas.js",
|
||||
"scripts": {
|
||||
|
@ -79,9 +79,8 @@ export default function path2D(ctx) {
|
||||
ctx.fill(path2);
|
||||
ctx.strokeStyle = "red";
|
||||
|
||||
let pNext = makePath(ctx);
|
||||
// add first path, transform path, twice size, move 100,10
|
||||
pNext.addPath(path2, new DOMMatrix([
|
||||
let scaledPath = makePath(ctx);
|
||||
scaledPath.addPath(path2, new DOMMatrix([
|
||||
2, 0,
|
||||
0, 1,
|
||||
0,
|
||||
@ -89,6 +88,6 @@ export default function path2D(ctx) {
|
||||
]));
|
||||
|
||||
ctx.scale(1 / 2, 1); // Reset scale so that stroke is not scaled.
|
||||
ctx.stroke(pNext);
|
||||
ctx.stroke(scaledPath);
|
||||
ctx.restore();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user