Skip to content

Commit 8e828f2

Browse files
authored
Allow disabling occlusion mask border (ankitects#2764)
* Allow setting occlusion mask border to zero * Switch to multi-line if statements cf. 9740393 * Enforce if statement braces in dprint --------- Co-authored-by: Glutanimate <[email protected]>
1 parent 14940a6 commit 8e828f2

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

.dprint.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"typescript": {
3-
"indentWidth": 4
3+
"indentWidth": 4,
4+
"useBraces": "always"
45
},
56
"json": {
67
"indentWidth": 4

ts/image-occlusion/review.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ function drawShape({
152152
ctx.lineWidth = strokeWidth;
153153
if (shape instanceof Rectangle) {
154154
ctx.fillRect(shape.left, shape.top, shape.width, shape.height);
155-
ctx.strokeRect(shape.left, shape.top, shape.width, shape.height);
155+
// ctx stroke methods will draw a visible stroke, even if the width is 0
156+
if (strokeWidth) {
157+
ctx.strokeRect(shape.left, shape.top, shape.width, shape.height);
158+
}
156159
} else if (shape instanceof Ellipse) {
157160
const adjustedLeft = shape.left + shape.rx;
158161
const adjustedTop = shape.top + shape.ry;
@@ -169,7 +172,9 @@ function drawShape({
169172
);
170173
ctx.closePath();
171174
ctx.fill();
172-
ctx.stroke();
175+
if (strokeWidth) {
176+
ctx.stroke();
177+
}
173178
} else if (shape instanceof Polygon) {
174179
const offset = getPolygonOffset(shape);
175180
ctx.save();
@@ -181,7 +186,9 @@ function drawShape({
181186
}
182187
ctx.closePath();
183188
ctx.fill();
184-
ctx.stroke();
189+
if (strokeWidth) {
190+
ctx.stroke();
191+
}
185192
ctx.restore();
186193
} else if (shape instanceof Text) {
187194
ctx.save();
@@ -267,13 +274,13 @@ function getShapeProperties(): ShapeProperties {
267274
? inActiveShapeColor
268275
: "#ffeba2",
269276
activeBorder: {
270-
width: activeShapeBorderWidth ? activeShapeBorderWidth : 1,
277+
width: !isNaN(activeShapeBorderWidth) ? activeShapeBorderWidth : 1,
271278
color: activeShapeBorderColor
272279
? activeShapeBorderColor
273280
: "#212121",
274281
},
275282
inActiveBorder: {
276-
width: inActiveShapeBorderWidth ? inActiveShapeBorderWidth : 1,
283+
width: !isNaN(inActiveShapeBorderWidth) ? inActiveShapeBorderWidth : 1,
277284
color: inActiveShapeBorderColor
278285
? inActiveShapeBorderColor
279286
: "#212121",

0 commit comments

Comments
 (0)