Shape magnet

12 views
Skip to first unread message

Gregory Tappero

unread,
Nov 23, 2009, 12:28:34 PM11/23/09
to Flex ObjectHandles
Hello there

I am in for some ideas on how to implement shapes magnetism the Object
Handle way for rotation = 0 as a 'first' version.

The end result will look like this:

http://screenr.com/clB

Let's say you have S1 S2 S3 in objectHandleSelectionManager.

set gravity to 5

On mouse down you build two arrays for fast look up.

Left Vertical (x) Top Horizontal (y) edge:
xSnapPositionsLeftEdge x - 5 to x + 5 (10 items) for all shapes top
left point.
ySnapPositionsTopEdge y - 5 to y + 5 (10 items) for all shapes top left point.

Right Vertical (x) Bottom Horizontal (y) edge::
xSnapPositionsRightEdge x+ width - 5 to x + width + 5 (10 items)
for all shapes bottom right point.
ySnapPositionsBottomEdge y + height - 5 to y + height + 5 (10 items)
for all shapes bottom right point.

Center ...

When S1 is moved you check if its top left corner matches any of the
value in xSnapPositionsLeftEdge for x and ySnapPositionsTopEdge for
y.
If it does you update the shape position to the x,y value of
currentlySelected at postion int( match position /10)
draw a nice axe on the shape parent plan.

Things i could have forgotten:
- Is currentlySelected really usable for this purpose ?
- Is it out of the scope of object Handles where each shape handles
its own movement and have no idea of the of the system.
- negative width / height

Thank you for your feedbacks.

Greg

Marc Hughes

unread,
Nov 23, 2009, 1:04:29 PM11/23/09
to object...@googlegroups.com
Are you thinking in OH1 or OH2 terms?

In the OH2 space, you do have a single ObjectHandles instance that you can register a bunch of objects with.  I think building it into there would make a lot of sense.  Perhaps as a custom constraint.  Perhaps "constraints" should even be renamed to something more general like "helpers" since I could imagine similar things.

If you're working in the OH1 space, I'd probably shoot for a separate manager that you register your ObjectHandles with and then it listens for the MOVING / RESIZING events and handles things accordingly.

If you snap to the bounding box instead of the rectangular coordinates, it would at least do something reasonable for rotated objects.

-Marc


--

You received this message because you are subscribed to the Google Groups "Flex ObjectHandles" group.
To post to this group, send email to object...@googlegroups.com.
To unsubscribe from this group, send email to objecthandle...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/objecthandles?hl=.



Gregory Tappero

unread,
Nov 23, 2009, 1:10:56 PM11/23/09
to object...@googlegroups.com
Hum i was looking at OH2.
Good trick for the bounding box !
Talking about bounding box, with oh1 i realised the bounding box of an
object 'includes' the handles which is kind of normal but when i do
multi select detection with intersect it is a little out of place (too
large) compare to the real shape drown Circle, rectangle etc.

For now i did my own getBound.

I will look at this magnet shape thing for OH2 I am sure it can get quite cool.

Greg

Marc Hughes

unread,
Nov 23, 2009, 2:11:47 PM11/23/09
to object...@googlegroups.com
In OH2, the handles aren't added to the component as children, so that wouldn't be a problem there :)

Looking forward to seeing what you come up with.

-Marc
Reply all
Reply to author
Forward
0 new messages