DiamondNode

class visualife.diagrams.DiamondNode(id, text, xc, yc, w, **attrs)

Bases: visualife.diagrams.RectNode

Draws 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 rectangle

param text:

(string) text to be displayed in the box

param xc:

(number) X of the bottom left corner

param yc:

(number) Y of the bottom left corner

param w:

(number) width of the box

param 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 its top(), left(), bottom() and right() 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

bottom Coordinates of the bottom vertex of this node
left Coordinates of the left vertex of this node
right Coordinates of the right vertex of this node
top Coordinates 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
left

Coordinates of the left vertex of this node

Returns:(Point) coordinates of the left vertex
right

Coordinates of the right vertex of this node

Returns:(Point) coordinates of the left vertex
top

Coordinates of the top vertex of this node

Returns:(Point) coordinates of the left vertex

Methods Documentation

draw(viewport, **kwargs)

Draw this dot node on a viewport.

Parameters: