|
30 | 30 | <div id="buttons" style="display: flex; justify-content: center; align-items: center;"> |
31 | 31 | <img onclick="undo()" id="dogState" src="https://files.reimage.dev/filesghs/1fe80cbebf47/original" width="60" height="60"> |
32 | 32 | <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"> |
33 | 34 | <img onclick="toggleEraser()" id="toolpic" src="https://files.reimage.dev/filesghs/a459809638ee/original" width="60" height="60"> |
34 | 35 | <img onclick="upload()" id="savepic" src="https://files.reimage.dev/filesghs/ae4d320d50bb/original" width="60" height="60"> |
35 | 36 | <img onclick="clearCanvas()" id="clearState" src="https://files.reimage.dev/filesghs/1ffb5bbb8772/original" width="60" height="60"> |
|
50 | 51 | let currentClearIndex = 0; |
51 | 52 | let currentDogIndex = 0; |
52 | 53 | let currentSaveIndex = 0; |
| 54 | +let currentColorIndex = 0; |
53 | 55 | let isEraser = false; |
54 | 56 |
|
55 | 57 |
|
|
85 | 87 | "https://files.reimage.dev/filesghs/b7f26beb6c54/original", // save successful |
86 | 88 | ]; |
87 | 89 |
|
| 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 | + |
88 | 110 | // Upload function |
89 | 111 | function upload() { |
90 | 112 | canvas.toBlob(async blob => { |
|
199 | 221 | return size; |
200 | 222 | } |
201 | 223 |
|
202 | | - |
| 224 | +//daVE nd maRGaux forever and ever |
203 | 225 |
|
204 | 226 | // Drawing function |
205 | 227 |
|
|
273 | 295 | canvas.addEventListener('touchend', () => { drawing = false; }); |
274 | 296 |
|
275 | 297 | addEventListener("keydown", (event) => { |
276 | | - if (event.key === "b" || event.key === "B") { |
277 | | - clearCanvas(); |
278 | | - } |
279 | 298 | if (event.key === "v" || event.key === "V") { |
280 | | - upload(); |
| 299 | + toggleEraser(); |
281 | 300 | } |
282 | 301 | if (event.key === "x" || event.key === "X") { |
283 | 302 | toggleBrushSize(); |
284 | 303 | } |
285 | 304 | if (event.key === "c" || event.key === "C") { |
286 | | - toggleEraser(); |
| 305 | + toggleColor(); |
287 | 306 | } |
288 | 307 | if (event.key === "z" || event.key === "Z") { |
289 | 308 | undo(); |
|
0 commit comments