License Public Domain
Lines 33
Keywords
flow charts (4) graphics (9) nodebox (8)
Included in this Library
Permissions
Owner: Theodore Test
Viewable by Everyone
Editable by All Siafoo Users
Hide
Writing an article is easy - try our reStructured Text demo Join Siafoo Now or Learn More

Nodebox Flow Chart Edges Atom Feed 0

In Brief Functions that generate edges (read: lines and pointers) for use in Nodebox flow chart graphing projects. Like the nodes functions, these should probably be reimplemented as classes eventually.... more
# 's
 1from utility_geometry import *
2
3def straight_flow_arrow(arg_x,arg_y,target_x,target_y,pointer_size=None,text_string='',back_stroke=0,draw_it=True):
4
5 a = angle(arg_x,arg_y,target_x,target_y)
6 d = distance(arg_x,arg_y,target_x,target_y)
7
8 # A default pointer size based on the length of the line.
9 if not pointer_size:
10 pointer_size = d*0.10
11
12 # We need some reference points for building the path.
13 line_end_x,line_end_y = coordinates(arg_x,arg_y,d-pointer_size,a)
14 pointer_tip_x,pointer_tip_y = coordinates(arg_x,arg_y,d,a)
15 left_back_x,left_back_y = coordinates(line_end_x,line_end_y,pointer_size,a-90-back_stroke)
16 right_back_x,right_back_y = coordinates(line_end_x,line_end_y,pointer_size,a+90+back_stroke)
17 mid_line_x,mid_line_y = coordinates(arg_x,arg_y,(d-pointer_size)/2.0,a)
18
19
20 # Actually generate the Bezier path.
21 beginpath(arg_x,arg_y)
22 lineto(line_end_x,line_end_y)
23 lineto(left_back_x,left_back_y)
24 lineto(pointer_tip_x,pointer_tip_y)
25 lineto(right_back_x,right_back_y)
26 lineto(line_end_x,line_end_y)
27 p = endpath(draw=draw_it)
28
29 tw = textwidth(text_string,WIDTH-mid_line_x)
30
31 push()
32 align(LEFT)
33 tp = textpath(text_string,mid_line_x+10,mid_line_y-5,width=WIDTH-mid_line_x)
34 pop()
35
36 if draw_it:
37 drawpath(tp)
38
39 return p

Functions that generate edges (read: lines and pointers) for use in Nodebox flow chart graphing projects. Like the nodes functions, these should probably be reimplemented as classes eventually.

Dependent on the Nodebox environment.

http://www.siafoo.net/image/69