Advertisement
Guest User

rektangel skalering

a guest
Apr 21st, 2019
100
0
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.       }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement