-
Notifications
You must be signed in to change notification settings - Fork 0
/
etch.js
31 lines (26 loc) · 825 Bytes
/
etch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const grid = document.getElementById("grid");
const setBtn = document.getElementById("btn");
const gridSize = document.getElementById("grid-selector");
const colorChoice = document.getElementById("color-selector");
const pixels = document.getElementsByClassName("square");
let pencil = colorChoice.value;
function makeGrid(size){
document.querySelectorAll(".square").forEach(e => e.remove());
grid.style.setProperty("--grid-size", size);
for (let i = 0; i < size * size; i++){
square = document.createElement("div");
square.className = "square";
grid.appendChild(square);
}
}
setBtn.addEventListener("click", e => {
makeGrid(gridSize.value);
}
)
colorChoice.addEventListener("input", e => {
pencil = colorChoice.value;
}
)
for (let j = 0; j <= pixels.length; j++){
;
}