-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColor Palette.html
More file actions
60 lines (55 loc) · 2.22 KB
/
Color Palette.html
File metadata and controls
60 lines (55 loc) · 2.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<script>
/* Form to adjust dimension*/
function Form() {
document.write('<br> <form id="dim">');
document.write(
'<label for="dim">Please fill in the cell with a table size:</label>'
);
document.write('<input type="number" id="sz" style="margin: 0px 15px">');
document.write(
"<button onclick=\"size=document.getElementById('sz').value; Output()\">Change dimension</button>"
);
document.write("</form>");
document.write("<p>Dimension: " + size + " x " + size + "</p>");
}
function RandInt(min, max) {
return Math.floor(Math.random() * (max - min) + min);
}
function Output() {
document.body.innerHTML = "";
document.write('<table border="1">');
for (let i = 0; i < size; i++) {
document.write("<tr>");
for (let j = 0; j < size; j++) {
document.write("<td width=50 height=50></td>");
}
document.write("</tr>");
}
document.write("</table>");
td = document.getElementsByTagName("td");
for (let i = 0; i < size * size; i++) {
r = RandInt(0, 255);
g = RandInt(0, 255);
b = RandInt(0, 255);
td[i].style.backgroundColor =
"rgb(" + r + "," + g + "," + b + ")";
}
Form();
document.write(
'<button onclick="Output()">Change palette</button> <br> <br>'
);
document.write(
'<button onclick="myInterval = setInterval(Output, 200)">Disco</button>'
);
}
size = 10;
Output();
</script>
</body>
</html>