ignore simulating unusable scale factor

This commit is contained in:
waltem01 2024-04-05 08:08:07 +02:00
parent cbcc5964d5
commit 80ca56992c

View File

@ -64,6 +64,7 @@
const y = parseInt((formData.get('y') as string) ?? matrix.height - 1); const y = parseInt((formData.get('y') as string) ?? matrix.height - 1);
const r = parseInt((formData.get('r') as string) ?? matrix.width / 2 - 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 // Convert stored color data to hex
const hex = rgbToHex(pixelColor); const hex = rgbToHex(pixelColor);
// Loop through angles // Loop through angles
@ -73,8 +74,7 @@
const ny = Math.round(Math.sin(toRadians(a)) * r + y); const ny = Math.round(Math.sin(toRadians(a)) * r + y);
// If within bounds, draw pixel with color // If within bounds, draw pixel with color
if (nx >= 0 && nx < 192 && ny >= 0 && ny < 192 && matrix.grid) if (nx >= 0 && nx < 192 && ny >= 0 && ny < 192) matrix.grid[ny][nx].color = hex;
matrix.grid[ny][nx].color = hex;
} }
} }
@ -89,7 +89,7 @@
// Convert stored color data to hex // Convert stored color data to hex
const hex = rgbToHex(pixelColor); const hex = rgbToHex(pixelColor);
// Loop through every position in rectangle to set color // 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; 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); const y = parseInt((formData.get('y') as string) ?? matrix.height - 1);
// Set singular coodinate to given color // 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 // Clear simulated matrix