-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdesigns.js
More file actions
46 lines (30 loc) · 1.22 KB
/
designs.js
File metadata and controls
46 lines (30 loc) · 1.22 KB
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
43
44
45
46
// Time complexity = 0(n*m)
const table =document.getElementById("pixelCanvas");
const color = document.getElementById("colorPicker");
function makeGrid() {
// Reset a Grid
table.innerHTML = "";
let gridHeight = document.getElementById("inputHeight").value;
let gridWidth = document.getElementById("inputWidth").value;
// make a Grid
for(let i = 0; i < gridHeight; i++){
let row = document.createElement("tr");
row.id = "row" + i;
table.appendChild(row);
let mainrow = document.getElementById("row" +i );
for(let j = 0; j < gridWidth; j++){
let td = document.createElement("td");
mainrow.appendChild(td);
// color the Element
// click to fill color in tableData box
td.addEventListener("click", function paint(){
td.style.backgroundColor = color.value;
//td.setAttribute("style", backgroundColor = color.value)
});
// Double click to remove filled color
td.addEventListener("dblclick",function removePaint(){
td.style.backgroundColor = '';
});
}
}
}