I’ve got a problem and I’m in like my 10th revision of code so maybe you all could help.
I am building a cut-down version of Visio so to speak, where you have shapes on the stage that allow you to connect between the two. So if you wanted to connect ShapeA(x:0,y:0) to Shape B (x:100, y:100) it is regarded as being in the TL corner. Thereby ShapeB’s faces available are North and West which can be connected - resulting in no lines crossing over into a shapes inner region.
The concept i want to implement is that when you drag your line connector over your intended drop shape, it snaps to the nearest face (North,East,South,West) aswell as the nearest position you were draging over… ie if the end Line connector node is in the bottom left corner of your drop shape and the nearest face is West, it would then maintain the Nodes.y position but snap the Nodes.x position to the intended shapes x.postion - resulting in a snapping concept being in play.
I can get this happening on two variations. First being line Interesects, where i could determine which face has actual line intersection, based on that it determines the face.
I have also tried measuring the distance between two points, finding the shortest one and snapping to the appropriate face.
The problem with these two basically are this. If you drag your line in a 45 degree angle, so that its basically in the dead center of North/West it can’t seem to determine the nearest face as its now either North/West?
I had implemented a Random Choice in the event this occures (ie randomly chooses between North or West).
Has anyone else done something of this nature? something along the lines of Line of Site mayabe?