DiamondNode¶
-
class
visualife.diagrams.DiamondNode(id, text, xc, yc, w, **attrs)¶ Bases:
visualife.diagrams.RectNodeDraws a diamond node.
This shape can be used to represent a conditional statement in block algorithms. Diamond node is derived from a RectNode; in fact its just a square rotated by 45 degrees
param id: (
string) id to be set to the SVG element of the rectangleparam text: (
string) text to be displayed in the boxparam xc: (
number) X of the bottom left cornerparam yc: (
number) Y of the bottom left cornerparam w: (
number) width of the boxparam attrs: see below
Keyword Arguments: - text_style (
string) – a dictionary holding style settings for text - node_style (
string) – a style for drawing
The example below creates a
DiamondNode. Four additional small dots mark itstop(),left(),bottom()andright()position.from browser import document from visualife.core import HtmlViewport from visualife.diagrams import DiamondNode, DotNode drawing = HtmlViewport(document['svg-dia'],200,100) box = DiamondNode("dia-1", "example box", 100, 80, 50) t = DotNode("dot-1a", box.top.x, box.top.y, 5) l = DotNode("dot-2a", box.left.x, box.left.y, 5) b = DotNode("dot-3a", box.bottom.x, box.bottom.y, 5) r = DotNode("dot-4a", box.right.x, box.right.y, 5) for shape in [box, t, l, b, r]: shape.draw(drawing) drawing.close()
Attributes Summary
bottomCoordinates of the bottom vertex of this node leftCoordinates of the left vertex of this node rightCoordinates of the right vertex of this node topCoordinates of the top vertex of this node Methods Summary
draw(viewport, **kwargs)Draw this dot node on a viewport. Attributes Documentation
-
bottom¶ Coordinates of the bottom vertex of this node
Returns: ( Point) coordinates of the left vertex
Methods Documentation
-
draw(viewport, **kwargs)¶ Draw this dot node on a viewport.
Parameters: - viewport – (
visualife.core.HtmlViewportorvisualife.core.SvgViewport) where to draw this node - kwargs – provide style to draw this dot with node_style and text_style keys
- viewport – (
- text_style (