From 80ca56992cf38ecffc36390a9957e87e863f82a5 Mon Sep 17 00:00:00 2001 From: waltem01 Date: Fri, 5 Apr 2024 08:08:07 +0200 Subject: [PATCH] ignore simulating unusable scale factor --- Webserver/src/routes/admin/+page.svelte | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Webserver/src/routes/admin/+page.svelte b/Webserver/src/routes/admin/+page.svelte index aba19a0..e89642c 100644 --- a/Webserver/src/routes/admin/+page.svelte +++ b/Webserver/src/routes/admin/+page.svelte @@ -64,6 +64,7 @@ const y = parseInt((formData.get('y') as string) ?? matrix.height - 1); const r = parseInt((formData.get('r') as string) ?? matrix.width / 2 - 1); + if (!matrix.grid || matrix.scale?.factor !== 1) return; // Convert stored color data to hex const hex = rgbToHex(pixelColor); // Loop through angles @@ -73,8 +74,7 @@ const ny = Math.round(Math.sin(toRadians(a)) * r + y); // If within bounds, draw pixel with color - if (nx >= 0 && nx < 192 && ny >= 0 && ny < 192 && matrix.grid) - matrix.grid[ny][nx].color = hex; + if (nx >= 0 && nx < 192 && ny >= 0 && ny < 192) matrix.grid[ny][nx].color = hex; } } @@ -89,7 +89,7 @@ // Convert stored color data to hex const hex = rgbToHex(pixelColor); // Loop through every position in rectangle to set color - if (!matrix.grid) return; + if (!matrix.grid || matrix.scale?.factor !== 1) return; for (let j = y; j < y + h; j++) for (let i = x; i < x + w; i++) matrix.grid[j][i].color = hex; } @@ -100,7 +100,7 @@ const y = parseInt((formData.get('y') as string) ?? matrix.height - 1); // Set singular coodinate to given color - if (matrix.grid) matrix.grid[y][x].color = rgbToHex(pixelColor); + if (matrix.grid && matrix.scale?.factor === 1) matrix.grid[y][x].color = rgbToHex(pixelColor); } // Clear simulated matrix