I've got an arrow that drives the movement of a rectangle. I need the arrow to move freeform, but the rectangle to look like it is snapping to a grid made of 10x15 rectangles. Is there a way to make the movement of the rectangle follow the arrow but still constrain to the grid?
Thanks
Alex
Moving by increments of 10 pixels
-
- Posts: 320
- Joined: June 26th, 2004, 10:01 am
- Location: Folsom, CA
- Contact:
Something like this maybe:
w = 10;
h = 15;
offset = [w,h]/2;
[Math.floor(value[0]/w)*w, Math.floor(value[1]/h)*h] + offset;
You'll probably want to fiddle with the offset til you get what you want.
Dan
w = 10;
h = 15;
offset = [w,h]/2;
[Math.floor(value[0]/w)*w, Math.floor(value[1]/h)*h] + offset;
You'll probably want to fiddle with the offset til you get what you want.
Dan