mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 15:23:44 +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() {
|
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,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user