This repository has been archived by the owner on Jan 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
script.js
43 lines (39 loc) · 1.58 KB
/
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
43
function setPixelColor(pixel) {
var penColor = document.getElementById("pen").value;
pixel.style.backgroundColor = penColor;
};
function resetbtn() {
var cols = document.getElementsByClassName("pixel");
for (i = 0; i < cols.length; i++) {
cols[i].style.backgroundColor = "white";
};
};
function gridtoggle() {
if (document.getElementById("art").style.borderSpacing !== "0px") {
document.getElementById("art").style.borderSpacing = "0px";
document.getElementById("gridtoggle").style.backgroundColor = "tomato";
} else if (document.getElementById("art").style.borderSpacing === "0px") {
document.getElementById("art").style.borderSpacing = "1px";
document.getElementById("gridtoggle").style.backgroundColor = "limegreen";
};
};
function bordertoggle() {
if (document.getElementById("art").style.borderStyle !== "hidden") {
document.getElementById("art").style.borderStyle = "hidden";
document.getElementById("bordertoggle").style.backgroundColor = "tomato";
} else if (document.getElementById("art").style.borderStyle === "hidden") {
document.getElementById("art").style.borderStyle = "solid";
document.getElementById("bordertoggle").style.backgroundColor = "limegreen";
};
};
function downloadbtn() {
var art = document.getElementById("art");
html2canvas(art, {
onrendered: function (canvas) {
var a = document.createElement("a");
a.href = canvas.toDataURL("image/png");
a.download = "pixelart.png";
a.click();
}
});
};