Skip to content

Commit 12949ba

Browse files
Add files via upload
1 parent 3d4b10b commit 12949ba

1 file changed

Lines changed: 25 additions & 6 deletions

File tree

drawing.html

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<div id="buttons" style="display: flex; justify-content: center; align-items: center;">
3131
<img onclick="undo()" id="dogState" src="https://files.reimage.dev/filesghs/1fe80cbebf47/original" width="60" height="60">
3232
<img onclick="toggleBrushSize()" id="brushsize" src="https://files.reimage.dev/filesghs/e291bce2b8ae/original" width="60" height="60">
33+
<img onclick="toggleColor()" id="colorswitch" src="https://files.reimage.dev/filesghs/59fe257f3694/original" width="60" height="60">
3334
<img onclick="toggleEraser()" id="toolpic" src="https://files.reimage.dev/filesghs/a459809638ee/original" width="60" height="60">
3435
<img onclick="upload()" id="savepic" src="https://files.reimage.dev/filesghs/ae4d320d50bb/original" width="60" height="60">
3536
<img onclick="clearCanvas()" id="clearState" src="https://files.reimage.dev/filesghs/1ffb5bbb8772/original" width="60" height="60">
@@ -50,6 +51,7 @@
5051
let currentClearIndex = 0;
5152
let currentDogIndex = 0;
5253
let currentSaveIndex = 0;
54+
let currentColorIndex = 0;
5355
let isEraser = false;
5456

5557

@@ -85,6 +87,26 @@
8587
"https://files.reimage.dev/filesghs/b7f26beb6c54/original", // save successful
8688
];
8789

90+
//color pic
91+
const colorSources = [
92+
"https://files.reimage.dev/filesghs/59fe257f3694/original", // black
93+
"https://files.reimage.dev/filesghs/c7cba54f3f00/original", // gray
94+
];
95+
96+
97+
98+
// color switch function
99+
let colors = ["black", "gray",];
100+
ctx.strokeStyle = colors[currentColorIndex];
101+
function toggleColor() {
102+
currentColorIndex = (currentColorIndex + 1) % colors.length;
103+
ctx.strokeStyle = colors[currentColorIndex];
104+
105+
const colorElement = document.getElementById('colorswitch');
106+
colorElement.src = colorSources[currentColorIndex];
107+
}
108+
109+
88110
// Upload function
89111
function upload() {
90112
canvas.toBlob(async blob => {
@@ -199,7 +221,7 @@
199221
return size;
200222
}
201223

202-
224+
//daVE nd maRGaux forever and ever
203225

204226
// Drawing function
205227

@@ -273,17 +295,14 @@
273295
canvas.addEventListener('touchend', () => { drawing = false; });
274296

275297
addEventListener("keydown", (event) => {
276-
if (event.key === "b" || event.key === "B") {
277-
clearCanvas();
278-
}
279298
if (event.key === "v" || event.key === "V") {
280-
upload();
299+
toggleEraser();
281300
}
282301
if (event.key === "x" || event.key === "X") {
283302
toggleBrushSize();
284303
}
285304
if (event.key === "c" || event.key === "C") {
286-
toggleEraser();
305+
toggleColor();
287306
}
288307
if (event.key === "z" || event.key === "Z") {
289308
undo();

0 commit comments

Comments
 (0)