Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ------------------------------------------------------------------- //
- // SquareSnap(xx,yy,x1,y1,x2,y2); //
- // Desc: Snaps a point to the closest side of a square from the inside //
- // Note: Replace "xx" and "yy" with the X and Y points you are setting //
- // ------------------------------------------------------------------- //
- //Variables
- var xDist,yDist;
- xDist = (argument0-argument2) - ((argument4-argument2)/2);
- yDist = (argument1-argument3) - ((argument5-argument3)/2);
- //Checking
- if abs(xDist) >= abs(yDist)
- if xDist >= 0 {xx = argument4; yy = argument1;} else {xx = argument2; yy = argument1;}
- else
- if yDist >= 0 {yy = argument5; xx = argument0;} else {yy = argument3; xx = argument0;}
Advertisement
Add Comment
Please, Sign In to add comment