mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 14:53:09 +08:00
remove stroke rounding
This commit is contained in:
parent
427f03fc07
commit
d312311f20
19
src/Shape.ts
19
src/Shape.ts
@ -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,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user