AllenYuan

draw.js first

Apr 30th, 2020
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function() {
  2.   const canvas = document.getElementById("mycanvas");
  3.   console.log(canvas);
  4.   let ctx = canvas.getContext("2d");
  5.   // get context to draw on canvas
  6.   let DIMENSION = 25;
  7.   let WIDTH = canvas.width;
  8.   let HEIGHT = canvas.height;
  9.  
  10.   ctx.strokeStyle = 'rgba(0,0,0,0.1)';
  11.   for (let i = 0; i < DIMENSION; ++i) {
  12.     x = Math.floor(i * WIDTH / DIMENSION);
  13.     ctx.beginPath();
  14.     ctx.moveTo(x, 0);
  15.     ctx.lineTo(x, HEIGHT);
  16.     ctx.stroke();
  17.  
  18.     y = Math.floor(i * HEIGHT / DIMENSION);
  19.     ctx.beginPath();
  20.     ctx.moveTo(0, y);
  21.     ctx.lineTo(WIDTH, y);
  22.     ctx.stroke();
  23.   }
  24. });
Advertisement
Add Comment
Please, Sign In to add comment