daily pastebin goal
32%
SHARE
TWEET

Untitled

a guest Mar 23rd, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var canvas, ctx, flag = false,
  2.         prevX = 0,
  3.         currX = 0,
  4.         prevY = 0,
  5.         currY = 0,
  6.         dot_flag = false;
  7.  
  8.     var x = "black",
  9.         y = 2;
  10.    
  11.     function init() {
  12.         canvas = document.getElementById('can');
  13.         ctx = canvas.getContext("2d");
  14.         w = canvas.width;
  15.         h = canvas.height;
  16.    
  17.        
  18.         canvas.addEventListener("mousedown", findxyd , false);
  19.  
  20.     }
  21.    
  22.    
  23.      
  24.    
  25.     function draw() {
  26.         ctx.beginPath();
  27.         ctx.moveTo(prevX, prevY);
  28.         ctx.lineTo(currX, currY);
  29.         ctx.strokeStyle = x;
  30.         ctx.lineWidth = y;
  31.         ctx.stroke();
  32.         ctx.closePath();
  33.     }
  34.    
  35.    
  36.    
  37.    
  38.    
  39.     function findxym(e) {
  40.            
  41.                 prevX = currX;
  42.                 prevY = currY;
  43.                 currX = e.clientX - canvas.offsetLeft;
  44.                 currY = e.clientY - canvas.offsetTop;
  45.                 draw()    
  46.        
  47.     }
  48.    
  49.     function findxyd(e) {
  50.             currX = e.clientX - canvas.offsetLeft;
  51.             currY = e.clientY - canvas.offsetTop;
  52.             canvas.addEventListener("mousemove", findxym , false);
  53.    
  54.            
  55.        
  56.     }
  57.    
  58.    
  59. init()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top