geometry-challenged
Thomas Bähler
toeloop at swissonline.ch
Sat Jan 24 19:15:59 EST 2004
Hi Richard
> I can draw a line object from the loc of one object to the loc of
> another.
> But if I want to draw only in the space _between_ objects rather than
> intersect them, how do I get the points for the location where a line
> object
> would meet the edge of the other objects if drawn all the way to their
> centers, as indicated by the "X"s below:
There might be a more ellegant solution to your problem but the one
below works.
It calculates a list of the rounded locations of every pixel of the
connecting line,
and checks then the first points of each end that are not within the
buttons.
Cheers
Thomas
on mouseUp
put the loc of button "Button 1" into LStart
put the loc of button "Button 2" into LStop
put (item 1 of LStop) - (item 1 of LStart) into DistX
put (item 2 of LStop) - (item 2 of LStart) into DistY
put round((DistX^2+DistY^2)^0.5) into LLength
put DistX/LLength into XStep
put DistY/LLength into YStep
put 0 into i
put empty into PList -- calculated pixel of the whole line
repeat LLength times
put i + 1 into i
put (item 1 of LStart) + round(XStep*i) & comma & (item 2 of
LStart) + round(YStep*i) & return after PList
end repeat
delete last char of PList
--search the first Border-Point
repeat with i = 1 to the number of lines of PList
if within(button "Button 1",line i of PList) then
next repeat
else
put line i of PList into LStart
exit repeat
end if
end repeat
--search the second Border-Point
repeat with i = (the number of lines of PList) down to 1
if within(button "Button 2",line i of PList) then
next repeat
else
put line i of PList into LStop
exit repeat
end if
end repeat
put LStart & comma & LStop into Punkte
set the points of graphic "ConnectingLine" to Punkte
end mouseUp
More information about the use-livecode
mailing list