js.js 410 B

123456789101112131415161718
  1. var c = document.getElementById("myCanvas");
  2. var ctx = c.getContext("2d");
  3. let selection = [];
  4. color.onchange = () => {
  5. selection.forEach((c) => (c.color = color.value));
  6. };
  7. c.onmousemove = ({ clientX, clientY, buttons }) => {
  8. if (buttons > 0) {
  9. ctx.fillStyle = color.value;
  10. ctx.beginPath();
  11. ctx.arc(clientX, clientY, size.value, 0, Math.PI * 2);
  12. ctx.closePath();
  13. ctx.fill();
  14. }
  15. };