- commit
- 0ea1c74a27a80413b0de73764dd5f2c82a93e157
- parent
- d718ccc382b8f48606eea1d6b90afd2e35034c75
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2020-12-17 18:47
increase size
Diffstat
M | canvas.js | 9 | +++++---- |
1 files changed, 5 insertions, 4 deletions
diff --git a/canvas.js b/canvas.js
@@ -1,11 +1,12 @@ -1 1 var size = 20; 1 2 var canvas = document.querySelector('canvas');2 -1 canvas.width = 16;3 -1 canvas.height = 16;-1 3 canvas.width = size; -1 4 canvas.height = size; 4 5 var ctx = canvas.getContext('2d'); 5 6 6 7 var onmove = function(event) {7 -1 var x = Math.floor((event.clientX - canvas.offsetLeft) / canvas.clientWidth * 16);8 -1 var y = Math.floor((event.clientY - canvas.offsetTop) / canvas.clientHeight * 16);-1 8 var x = Math.floor((event.clientX - canvas.offsetLeft) / canvas.clientWidth * size); -1 9 var y = Math.floor((event.clientY - canvas.offsetTop) / canvas.clientHeight * size); 9 10 10 11 ctx.fillStyle = 'black'; 11 12 ctx.fillRect(x, y, 1, 1);