Next: contour, Previous: featpost3D, Up: Base modules
flowchart
This package provides routines to assist in drawing flowcharts. The primary
struct
is a block
, which represents a single block on the
flowchart.
pair block.boundThe upper right corner of the block relative to its lower left corner.
pair block.llcornerThe absolute lower left corner of the block.
pair block.center() void block.center(pair loc)Returns the current absolute center of the block, or sets the absolute center of the block.
pair block.position(real x)Returns an absolute position along the border path of the block.
pair block.top() pair block.left() pair block.right() pair block.bottom() pair block.topleft() pair block.topright() pair block.bottomleft() pair block.bottomright()These eight methods return an absolute position on the appropriate edge of the block.
picture block.draw(pen p=currentpen)
Returns a frame representing the block.
The following block generation routines accept a Label, string, or frame for their object argument.
block rectangle(object header, object body, pen headercolor=mediumgray, pen bodycolor=currentpen, pair center=(0,0), real dx=3) block rectangle(object body, pen headercolor=mediumgray, pen bodycolor=currentpen, pair center=(0,0), real dx=3)Create a rectangular block with the given header (if specified) and body. Here
dx
is the amount of padding around the header and body.
block diamond(object body, pair center=(0,0), real ds=5, real dw=1, real height=20, real dh=0)Create a diamond-shaped chart block.
block circle(object body, pair center=(0,0), real dr=3)Create a circular chart block.
block roundrectangle(object body, pair center=(0,0), real ds=5, real dw=0)Create a rectangular chart block with rounded corners.
block bevel(object body, pair center=(0,0), real dh=5, real dw=5)Create a rectangular chart block with beveled edges.
path path(pair point[] ... bool horizontal[])Draw paths joining the pairs in
point
with right-angled lines.
The entries in horizontal
identify whether successive
segments between the pairs specified by point
should be drawn
horizontal (true
) or vertical (false
).
Here is a simple flowchart example:
import flowchart; block block1=rectangle("Start",(-50,300)); block block1=rectangle("Example",pack("Start:","","$A:=0$","$B:=1$"), (-50,300)); block block2=diamond("Choice?",(0,200)); block block3=roundrectangle("Do something",(-100,100)); block block4=bevel("Don't do something",(100,100)); block block5=circle("End",(0,0)); draw(block1); draw(block2); draw(block3); draw(block4); draw(block5); draw(path(new pair[]{block1.right(),block2.top()},Horizontal), Arrow,PenMargin); draw(Label("Yes",0.5),path(new pair[]{block2.left(),block3.top()}, Horizontal),Arrow,PenMargin); draw(Label("Yes",0.5),path(new pair[]{block2.left(),block3.top()}, Horizontal),Arrow,PenMargin); draw(Label("No",0.5,N),path(new pair[]{block2.right(),block4.top()}, Horizontal),Arrow,PenMargin); draw(path(new pair[]{block3.bottom(),block5.left()},Vertical), Arrow,PenMargin); draw(path(new pair[]{block4.bottom(),block5.right()},Vertical), Arrow,PenMargin);