From 5689d96ef69911762e83ac9ec6a3d00d08057193 Mon Sep 17 00:00:00 2001 From: pgallino Date: Thu, 14 Nov 2024 14:05:04 -0300 Subject: [PATCH 1/2] Refactor: RoundRect to Select Devices --- src/types/devices/device.ts | 13 +++---------- src/utils.ts | 3 ++- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/types/devices/device.ts b/src/types/devices/device.ts index e1a7e966..4b7c2024 100644 --- a/src/types/devices/device.ts +++ b/src/types/devices/device.ts @@ -211,16 +211,9 @@ export class Device extends Sprite { // Increase the square size const size = this.width; // Side length of the square, now larger - // Draw a square using moveTo and lineTo - this.highlightMarker.moveTo(-size / 2, -size / 2); // Move to the top left corner of the centered square - this.highlightMarker.lineTo(size / 2, -size / 2); // Top line - this.highlightMarker.lineTo(size / 2, size / 2); // Right line - this.highlightMarker.lineTo(-size / 2, size / 2); // Bottom line - this.highlightMarker.lineTo(-size / 2, -size / 2); // Left line, closes the square - - // Change color to red and increase line thickness - this.highlightMarker.stroke({ width: 3, color: Colors.Violet }); // Red and thicker - + this.highlightMarker.roundRect(-this.width / 2, -this.height / 2, this.width, this.height, 5); + this.highlightMarker.stroke({ width: 3, color: Colors.Violet, alpha: 0.6 }); + this.highlightMarker.fill({color: Colors.Violet, alpha: 0.1}); this.highlightMarker.zIndex = ZIndexLevels.Device; // Ensure the marker is in the same container as the viewport diff --git a/src/utils.ts b/src/utils.ts index b6df45ed..feca72be 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,4 @@ -import { GraphicsContext } from "pixi.js"; +import { Graphics, GraphicsContext } from "pixi.js"; export enum Colors { Violet = 0x4b0082, @@ -8,6 +8,7 @@ export enum Colors { Red = 0xff0000, White = 0xffffff, Black = 0x000000, + Yellow = 0xffff00, } export function circleGraphicsContext( From 282ed0a6832f6bb7070b16adb376938673e3e0e3 Mon Sep 17 00:00:00 2001 From: pgallino Date: Thu, 14 Nov 2024 14:07:01 -0300 Subject: [PATCH 2/2] fix: lint errors --- src/types/devices/device.ts | 19 +++++++++++++------ src/utils.ts | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/types/devices/device.ts b/src/types/devices/device.ts index 4b7c2024..3f16b66a 100644 --- a/src/types/devices/device.ts +++ b/src/types/devices/device.ts @@ -208,12 +208,19 @@ export class Device extends Sprite { // Create the square as a selection marker this.highlightMarker = new Graphics(); - // Increase the square size - const size = this.width; // Side length of the square, now larger - - this.highlightMarker.roundRect(-this.width / 2, -this.height / 2, this.width, this.height, 5); - this.highlightMarker.stroke({ width: 3, color: Colors.Violet, alpha: 0.6 }); - this.highlightMarker.fill({color: Colors.Violet, alpha: 0.1}); + this.highlightMarker.roundRect( + -this.width / 2, + -this.height / 2, + this.width, + this.height, + 5, + ); + this.highlightMarker.stroke({ + width: 3, + color: Colors.Violet, + alpha: 0.6, + }); + this.highlightMarker.fill({ color: Colors.Violet, alpha: 0.1 }); this.highlightMarker.zIndex = ZIndexLevels.Device; // Ensure the marker is in the same container as the viewport diff --git a/src/utils.ts b/src/utils.ts index feca72be..b35ad0ce 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,4 @@ -import { Graphics, GraphicsContext } from "pixi.js"; +import { GraphicsContext } from "pixi.js"; export enum Colors { Violet = 0x4b0082,