Re: drawing while dragging
Re: drawing while dragging
- Subject: Re: drawing while dragging
- From: Tim Ramsey <email@hidden>
- Date: Tue, 22 Jul 2003 07:08:44 -0500
Hi,
I added the possibility in my app to draw a line between two objects
while the user drags the mouse. Based on the Sketch.app example, I
have most of it working. What I would like to do is to draw the line
as is done in IB when setting actions and outlets. So, not a
straight line, but one with 90 degree angles, in order to make it
look less messy/cluttered.
Any suggestions on how to approach this?
thanks,
- Koen.
______
You will want to subdivide your line into 3 segments. The middle
segment should have the longest run and may be horizontal or
vertical, so:
Compute delta X and delta Y from your line endpoints (x1,y1) and (x2,y2).
If delta X is bigger you will make 2 vertical and 1 horizontal
segment, otherwise...
Find the midpoint of the original line = (x3,y3).
Suppose delta X is bigger:
Draw the lines (x1,y1) to (x1,y3), (x1,y3) to (x2,y3) and (x2,y3) to (x2,y2)
otherwise
Draw the lines (x1,y1) to (x3,y1), (x3,y1) to (x3,y2) and (x3,y2) to (x2,y2)
If I have had enough coffee this morning, I have typed this
correctly, but you should see the principal anyway.
--
Tim
----> Learn as if you will live forever
----> Live as if you will die tomorrow Gandhi
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.