-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
42 lines (37 loc) · 965 Bytes
/
script.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
32
33
34
35
36
37
38
39
40
41
42
let brush_color = "black";
// let hold_checker = false;
function color(div){
div.target.style.backgroundColor = brush_color;
}
function reset(){
let canvas = document.querySelectorAll(".grid-items");
canvas.forEach((pixel)=>{
pixel.style.backgroundColor = "white";
});
}
function options(button){
console.log(button.target);
if(button.target.id == "white"){
brush_color = "white";
}
else if(button.target.id == "black"){
brush_color = "black" ;
}
else{
reset();
}
}
const buttons = document.querySelectorAll(".w");
buttons.forEach((button)=>{
button.addEventListener('click',options);
});
// window.addEventListener('onmousedown',()=>{
// hold_checker = true;
// });
// window.addEventListener('onmouseup',()=>{
// hold_checker = false;
// });
let divs = document.querySelectorAll(".grid-items");
divs.forEach((div)=>{
div.addEventListener('mouseover',color);
});