remove stroke rounding

This commit is contained in:
Tom Esterez 2022-03-08 14:23:54 +01:00
parent 427f03fc07
commit d312311f20

View File

@ -198,9 +198,7 @@ export class Shape<
} }
getContext() { getContext() {
Util.warn( Util.warn('shape.getContext() method is deprecated. Please do not use it.');
'shape.getContext() method is deprecated. Please do not use it.'
);
return this.getLayer().getContext(); return this.getLayer().getContext();
} }
getCanvas() { getCanvas() {
@ -537,22 +535,15 @@ export class Shape<
const width = preWidth + blurRadius * 2; const width = preWidth + blurRadius * 2;
const height = preHeight + blurRadius * 2; const height = preHeight + blurRadius * 2;
// if stroke, for example = 3
// we need to set x to 1.5, but after Math.round it will be 2
// as we have additional offset we need to increase width and height by 1 pixel
let roundingOffset = 0;
if (Math.round(strokeWidth / 2) !== strokeWidth / 2) {
roundingOffset = 1;
}
const rect = { const rect = {
width: width + roundingOffset, width,
height: height + roundingOffset, height,
x: x:
-Math.round(strokeWidth / 2 + blurRadius) + -(strokeWidth / 2 + blurRadius) +
Math.min(shadowOffsetX, 0) + Math.min(shadowOffsetX, 0) +
fillRect.x, fillRect.x,
y: y:
-Math.round(strokeWidth / 2 + blurRadius) + -(strokeWidth / 2 + blurRadius) +
Math.min(shadowOffsetY, 0) + Math.min(shadowOffsetY, 0) +
fillRect.y, fillRect.y,
}; };