Skip to content

Commit 6cf23f2

Browse files
authored
Refactor: RoundRect to Select Devices (#49)
1 parent aea184d commit 6cf23f2

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/types/devices/device.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -208,19 +208,19 @@ export class Device extends Sprite {
208208
// Create the square as a selection marker
209209
this.highlightMarker = new Graphics();
210210

211-
// Increase the square size
212-
const size = this.width; // Side length of the square, now larger
213-
214-
// Draw a square using moveTo and lineTo
215-
this.highlightMarker.moveTo(-size / 2, -size / 2); // Move to the top left corner of the centered square
216-
this.highlightMarker.lineTo(size / 2, -size / 2); // Top line
217-
this.highlightMarker.lineTo(size / 2, size / 2); // Right line
218-
this.highlightMarker.lineTo(-size / 2, size / 2); // Bottom line
219-
this.highlightMarker.lineTo(-size / 2, -size / 2); // Left line, closes the square
220-
221-
// Change color to red and increase line thickness
222-
this.highlightMarker.stroke({ width: 3, color: Colors.Violet }); // Red and thicker
223-
211+
this.highlightMarker.roundRect(
212+
-this.width / 2,
213+
-this.height / 2,
214+
this.width,
215+
this.height,
216+
5,
217+
);
218+
this.highlightMarker.stroke({
219+
width: 3,
220+
color: Colors.Violet,
221+
alpha: 0.6,
222+
});
223+
this.highlightMarker.fill({ color: Colors.Violet, alpha: 0.1 });
224224
this.highlightMarker.zIndex = ZIndexLevels.Device;
225225

226226
// Ensure the marker is in the same container as the viewport

src/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export enum Colors {
88
Red = 0xff0000,
99
White = 0xffffff,
1010
Black = 0x000000,
11+
Yellow = 0xffff00,
1112
}
1213

1314
export function circleGraphicsContext(

0 commit comments

Comments
 (0)