Allow disabling occlusion mask border (#2764)

* Allow setting occlusion mask border to zero

* Switch to multi-line if statements

cf. 9740393d72

* Enforce if statement braces in dprint

---------

Co-authored-by: Glutanimate <glutanimate@users.noreply.github.com>
This commit is contained in:
Aristotelis 2023-10-23 03:43:37 +02:00 committed by GitHub
parent 14940a617b
commit 8e828f2955
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View file

@ -1,6 +1,7 @@
{
"typescript": {
"indentWidth": 4
"indentWidth": 4,
"useBraces": "always"
},
"json": {
"indentWidth": 4

View file

@ -152,7 +152,10 @@ function drawShape({
ctx.lineWidth = strokeWidth;
if (shape instanceof Rectangle) {
ctx.fillRect(shape.left, shape.top, shape.width, shape.height);
// ctx stroke methods will draw a visible stroke, even if the width is 0
if (strokeWidth) {
ctx.strokeRect(shape.left, shape.top, shape.width, shape.height);
}
} else if (shape instanceof Ellipse) {
const adjustedLeft = shape.left + shape.rx;
const adjustedTop = shape.top + shape.ry;
@ -169,7 +172,9 @@ function drawShape({
);
ctx.closePath();
ctx.fill();
if (strokeWidth) {
ctx.stroke();
}
} else if (shape instanceof Polygon) {
const offset = getPolygonOffset(shape);
ctx.save();
@ -181,7 +186,9 @@ function drawShape({
}
ctx.closePath();
ctx.fill();
if (strokeWidth) {
ctx.stroke();
}
ctx.restore();
} else if (shape instanceof Text) {
ctx.save();
@ -267,13 +274,13 @@ function getShapeProperties(): ShapeProperties {
? inActiveShapeColor
: "#ffeba2",
activeBorder: {
width: activeShapeBorderWidth ? activeShapeBorderWidth : 1,
width: !isNaN(activeShapeBorderWidth) ? activeShapeBorderWidth : 1,
color: activeShapeBorderColor
? activeShapeBorderColor
: "#212121",
},
inActiveBorder: {
width: inActiveShapeBorderWidth ? inActiveShapeBorderWidth : 1,
width: !isNaN(inActiveShapeBorderWidth) ? inActiveShapeBorderWidth : 1,
color: inActiveShapeBorderColor
? inActiveShapeBorderColor
: "#212121",