mirror of
https://gitlab1.ptb.de/waltem01/Matrix
synced 2024-11-12 16:03:50 +00:00
commented matrix.ts file
This commit is contained in:
parent
d3016684f3
commit
a3e54d5f09
@ -1,14 +1,16 @@
|
||||
// Interface to represent a singualr matrix cell object
|
||||
export interface MatrixCell {
|
||||
xIndex: number;
|
||||
yIndex: number;
|
||||
x: number;
|
||||
y: number;
|
||||
color: string;
|
||||
}
|
||||
|
||||
// Create a 2D array containing MatrixCell objects with bg-color: black
|
||||
export function initializeMatrix(scaling: number): MatrixCell[][] {
|
||||
return Array.from({ length: 192 / scaling }, (_, yIndex) =>
|
||||
return Array.from({ length: 192 / scaling }, (_, y) =>
|
||||
Array.from(
|
||||
{ length: 192 / scaling },
|
||||
(_, xIndex) => ({ xIndex, yIndex, color: '000000' }) as MatrixCell
|
||||
(_, x) => ({ x, y, color: '000000' }) as MatrixCell
|
||||
)
|
||||
) as MatrixCell[][];
|
||||
}
|
||||
|
@ -579,12 +579,12 @@
|
||||
on:mouseup|preventDefault={() => (mousePressed = false)}
|
||||
>
|
||||
{#each matrix as row}
|
||||
<tr data-y={row[0].yIndex}>
|
||||
<tr data-y={row[0].y}>
|
||||
{#each row as cell}
|
||||
<td
|
||||
data-x={cell.xIndex}
|
||||
data-x={cell.x}
|
||||
style="padding: {padding}rem; background-color: #{getContrastColor(cell.color)}"
|
||||
class="{gamepad && gameCoords.x === cell.xIndex && gameCoords.y === cell.yIndex
|
||||
class="{gamepad && gameCoords.x === cell.x && gameCoords.y === cell.y
|
||||
? 'opacity-50'
|
||||
: 'opacity-0'} hover:opacity-50"
|
||||
on:mousemove={setMousePixel}
|
||||
|
Loading…
Reference in New Issue
Block a user