SHARE
TWEET

rektangel skalering

a guest Apr 21st, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   function drawRect(position) {
  2.       ctx.beginPath();
  3.       // draw a new rect from the start position
  4.       // to the current mouse position
  5.       ctx.strokeRect(dragStartLocation.x, dragStartLocation.y, Math.abs(dragStartLocation.x - position.x), Math.abs(dragStartLocation.y - position.y));     //- Stian: Her settes stroke på figuren
  6.       ctx.fillRect(dragStartLocation.x, dragStartLocation.y, Math.abs(dragStartLocation.x - position.x), Math.abs(dragStartLocation.y - position.y));
  7.   }  
  8.  
  9. // Event for mouse move
  10.   function mouseMove(aEvent) {
  11.       var pos = getMousePos(aEvent);
  12.  
  13.       var position;
  14.  
  15.       if (dragging === true && selectedShape === "Rectangle") {
  16.           restoreSnapshot();
  17.           position = pos;
  18.           drawRect(position);
  19.       }
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