-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
29 lines (22 loc) · 813 Bytes
/
Copy pathapp.js
File metadata and controls
29 lines (22 loc) · 813 Bytes
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
const ImageElement = document.getElementById("Image");
function createNewImage() {
const imgHeight = ImageElement.clientHeight;
const imgWidth = ImageElement.clientWidth;
let allRows = '';
for (let y = 0; y < imgHeight; y++) {
let row = '<div class="image-row" style="height: 1px;">';
for (let x = 0; x < imgWidth; x++) {
row += `<div class="singleton" style="background: ${randomColor()}; width: 1px; height: 1px;"></div>`;
}
row += '</div>';
allRows += row;
}
ImageElement.innerHTML = allRows;
}
const randomColor = () => {
return '#' + Math.floor(Math.random()*16777215).toString(16).padEnd(6, '0');
};
document.getElementById("Refresh").addEventListener("click", () => {
window.location.reload();
});
createNewImage();