5. obfc.js: Creating Lines

This post introduces draw_theLine and Line function to connect two objects. 

Creating Lines Between Two Objects

Line is a function that determines the path for given two objects and their positions. This function has 9 parameters. First two parameter is required and others are optimal.

Line(object1, object2, position1, position2, _text, _text_size, _description, _stroke_color, _text_color)

 


There are four start / end points for a shape. This example shows these points: Top:0, Bottom:1, Left:2 and Right: 3. Javascript codes:

In this example, we create Line to the draw_theLine function. The line has two parameters that are two objects obtained from shape creation. The algorithm takes into consideration four points of two shapes and calculates / finds minimum distance between these points. Moreover, you can determine these points manually. For example:

 

In this example, position informations are added to link two objects. For example, 0 means top of object1 and 1 means bottom of object2. There are three line in this exaple. Moreover, obfc.js has jumping mechanism:) in collision of lines.
There are five extra parameters: _text, _text_size, description, _stroke_color, _text_color. 

 

-1 or null in value of positions means that find minimum distance between two objects. Line function determines the longest sub-line for writing text middle of this line.