mirror of
https://codeberg.org/vlw/crtjs.git
synced 2025-09-13 18:03:40 +02:00
29 lines
No EOL
654 B
JavaScript
29 lines
No EOL
654 B
JavaScript
export class FluorescentScreen {
|
|
|
|
constructor(screen) {
|
|
this.screen = screen;
|
|
this.pixels = [];
|
|
|
|
this.spawnPixels();
|
|
}
|
|
|
|
createMatrix() {
|
|
this.screen.style.setProperty("grid-template-columns",`repeat(${this.screen.clientWidth},1px)`);
|
|
this.screen.style.setProperty("grid-template-rows",`repeat(${this.screen.clientHeight},1px)`);
|
|
}
|
|
|
|
spawnPixels() {
|
|
const density = this.screen.clientWidth * this.screen.clientHeight;
|
|
|
|
for(let i = 0; i < density; i++) {
|
|
const pixel = document.createElement("div");
|
|
pixel.classList.add("pixel");
|
|
|
|
this.screen.appendChild(pixel);
|
|
this.pixels.push(pixel);
|
|
}
|
|
|
|
this.createMatrix();
|
|
}
|
|
|
|
} |