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() {
Util.warn(
'shape.getContext() method is deprecated. Please do not use it.'
);
Util.warn('shape.getContext() method is deprecated. Please do not use it.');
return this.getLayer().getContext();
}
getCanvas() {
@ -537,22 +535,15 @@ export class Shape<
const width = preWidth + 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 = {
width: width + roundingOffset,
height: height + roundingOffset,
width,
height,
x:
-Math.round(strokeWidth / 2 + blurRadius) +
-(strokeWidth / 2 + blurRadius) +
Math.min(shadowOffsetX, 0) +
fillRect.x,
y:
-Math.round(strokeWidth / 2 + blurRadius) +
-(strokeWidth / 2 + blurRadius) +
Math.min(shadowOffsetY, 0) +
fillRect.y,
};