Module h2o_wave.graphics
Functions
circle
Draw a circle. See https://developer.mozilla.org/en-US/docs/Web/SVG/Element/circle
Args
kwargs
- Attributes to use for the initial render. SVG attributes, snake-cased.
Returns
Data for the graphical element.
draw
ellipse
Draw an ellipse. See https://developer.mozilla.org/en-US/docs/Web/SVG/Element/ellipse
Args
kwargs
- Attributes to use for the initial render. SVG attributes, snake-cased.
Returns
Data for the graphical element.
image
Draw an image. See https://developer.mozilla.org/en-US/docs/Web/SVG/Element/image
Args
kwargs
- Attributes to use for the initial render. SVG attributes, snake-cased.
Returns
Data for the graphical element.
line
Draw a line. See https://developer.mozilla.org/en-US/docs/Web/SVG/Element/line
Args
kwargs
- Attributes to use for the initial render. SVG attributes, snake-cased.
Returns
Data for the graphical element.
path
Draw a path. See https://developer.mozilla.org/en-US/docs/Web/SVG/Element/path
Args
kwargs
- Attributes to use for the initial render. SVG attributes, snake-cased.
Returns
Data for the graphical element.
polygon
Draw a polygon. See https://developer.mozilla.org/en-US/docs/Web/SVG/Element/polygon
Args
kwargs
- Attributes to use for the initial render. SVG attributes, snake-cased.
Returns
Data for the graphical element.
polyline
Draw a polyline. See https://developer.mozilla.org/en-US/docs/Web/SVG/Element/polyline
Args
kwargs
- Attributes to use for the initial render. SVG attributes, snake-cased.
Returns
Data for the graphical element.
rect
Draw a rectangle. See https://developer.mozilla.org/en-US/docs/Web/SVG/Element/rect
Args
kwargs
- Attributes to use for the initial render. SVG attributes, snake-cased.
Returns
Data for the graphical element.
reset
scene
Create a scene. A scene holds graphic elements whose attributes need to be changed dynamically (causing a re-render). The return value must be assigned to the scene()
property of a GraphicsCard
.
Args
kwargs
- Graphical elements to render as part of the scene.
Returns
A Data
instance.
spline
Draw a spline.
If x, y are specified, draws a regular spline.
If x, y, y0 are specified, draws a horizontal area spline. Sets baseline to zero if y0 is an empty list.
If x, x0, y are specified, draws a vertical area spline. Sets baseline to zero if x0 is an empty list
Missing information is rendered as gaps in the spline.
Args
x
- x-coordinates.
y
- y-coordinates.
x0
- base x-coordinates.
y0
- base y-coordinates.
curve
- Interpolation. One of basis, basis-closed, basis-open, cardinal, cardinal-closed, cardinal-open, smooth, smooth-closed, smooth-open, linear, linear-closed, monotone-x, monotone-y, natural, step, step-after, step-before. Defaults to linear.
radial
- Whether (x, y) should be treated as (angle,radius) or (x0, x, y0, y) should be treated as (start-angle, end-angle, inner-radius, outer-radius).
kwargs
- Attributes to use for the initial render. SVG attributes, snake-cased.
Returns
Data for the graphical element.
stage
Create a stage. A stage holds static graphics elements that are rendered as part of the background (behind the scene). The return value must be assigned to the stage()
property of a GraphicsCard
.
Args
kwargs
- Graphical elements to render as part of the stage.
Returns
Packed data.
text
Draw text. See https://developer.mozilla.org/en-US/docs/Web/SVG/Element/text
Args
text
- The text content.
kwargs
- Attributes to use for the initial render. SVG attributes, snake-cased.
Returns
Data for the graphical element.
turtle
type_of
Classes
Path
A convenience class for drawing SVG paths.
Methods
A
Draws an elliptical arc from the current point to (x, y). The size and orientation of the ellipse are defined by two radii (rx, ry) and an x_axis_rotation
, which indicates how the ellipse as a whole is rotated, in degrees, relative to the current coordinate system. The center (cx, cy) of the ellipse is calculated automatically to satisfy the constraints imposed by the other parameters. large_arc
and sweep_flag
contribute to the automatic calculations and help determine how the arc is drawn. In absolute coordinates.
See https://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands
Args
rx
- x-radius
ry
- y-radius
x_axis_rotation
- Rotation in degrees.
large_arc
- Determines if the arc should be greater than or less than 180 degrees.
sweep
- Determines if the arc should begin moving at positive angles or negative ones.
x
- x-coordinate
y
- y-coordinate
Returns
The current Path
instance.
C
Draws a cubic Bézier curve from the current point to (x,y) using (x1,y1) as the control point at the beginning of the curve and (x2,y2) as the control point at the end of the curve. In absolute coordinates.
See https://www.w3.org/TR/SVG/paths.html#PathDataCubicBezierCommands
Args
x1
- x-coordinate of first control point
y1
- y-coordinate of first control point
x2
- x-coordinate of second control point
y2
- y-coordinate of second control point
x
- x-coordinate
y
- y-coordinate
Returns
The current Path
instance.
H
Draws a horizontal line from the current point. In absolute coordinates.
See https://www.w3.org/TR/SVG/paths.html#PathDataLinetoCommands
Args
x
- x-coordinate
Returns
The current Path
instance.
L
Draw a line from the current point to the given (x,y) coordinate which becomes the new current point. In absolute coordinates.
See https://www.w3.org/TR/SVG/paths.html#PathDataLinetoCommands
Args
x
- x-coordinate
y
- y-coordinate
Returns
The current Path
instance.
M
Start a new sub-path at the given (x,y) coordinates. In absolute coordinates.
See https://www.w3.org/TR/SVG/paths.html#PathDataMovetoCommands
Args
x
- x-coordinate
y
- y-coordinate
Returns
The current Path
instance.
Q
Draws a quadratic Bézier curve from the current point to (x,y) using (x1,y1) as the control point. In absolute coordinates.
See https://www.w3.org/TR/SVG/paths.html#PathDataQuadraticBezierCommands
Args
x1
- x-coordinate of first control point
y1
- y-coordinate of first control point
x
- x-coordinate
y
- y-coordinate
Returns
The current Path
instance.
S
Draws a cubic Bézier curve from the current point to (x,y). The first control point is assumed to be the reflection of the second control point on the previous command relative to the current point. (x2,y2) is the second control point (i.e., the control point at the end of the curve). In absolute coordinates.
See https://www.w3.org/TR/SVG/paths.html#PathDataCubicBezierCommands
Args
x2
- x-coordinate of second control point
y2
- y-coordinate of second control point
x
- x-coordinate
y
- y-coordinate
Returns
The current Path
instance.
T
Draws a quadratic Bézier curve from the current point to (x,y). The control point is assumed to be the reflection of the control point on the previous command relative to the current point. In absolute coordinates.
See https://www.w3.org/TR/SVG/paths.html#PathDataQuadraticBezierCommands
Args
x
- x-coordinate
y
- y-coordinate
Returns
The current Path
instance.
V
Draws a vertical line from the current point. In absolute coordinates.
See https://www.w3.org/TR/SVG/paths.html#PathDataLinetoCommands
Args
y
- y-coordinate
Returns
The current Path
instance.
Z
Close the current subpath by connecting it back to the current subpath's initial point.
See https://www.w3.org/TR/SVG/paths.html#PathDataClosePathCommand
Returns
The current Path
instance.
a
Draws an elliptical arc from the current point to (x, y). The size and orientation of the ellipse are defined by two radii (rx, ry) and an x_axis_rotation
, which indicates how the ellipse as a whole is rotated, in degrees, relative to the current coordinate system. The center (cx, cy) of the ellipse is calculated automatically to satisfy the constraints imposed by the other parameters. large_arc
and sweep_flag
contribute to the automatic calculations and help determine how the arc is drawn. In relative coordinates.
See https://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands
Args
rx
- x-radius
ry
- y-radius
x_axis_rotation
- Rotation in degrees.
large_arc
- Determines if the arc should be greater than or less than 180 degrees.
sweep
- Determines if the arc should begin moving at positive angles or negative ones.
x
- x-coordinate
y
- y-coordinate
Returns
The current Path
instance.
c
Draws a cubic Bézier curve from the current point to (x,y) using (x1,y1) as the control point at the beginning of the curve and (x2,y2) as the control point at the end of the curve. In relative coordinates.
See https://www.w3.org/TR/SVG/paths.html#PathDataCubicBezierCommands
Args
x1
- x-coordinate of first control point
y1
- y-coordinate of first control point
x2
- x-coordinate of second control point
y2
- y-coordinate of second control point
x
- x-coordinate
y
- y-coordinate
Returns
The current Path
instance.
d
h
Draws a horizontal line from the current point. In relative coordinates.
See https://www.w3.org/TR/SVG/paths.html#PathDataLinetoCommands
Args
x
- x-coordinate
Returns
The current Path
instance.
l
Draw a line from the current point to the given (x,y) coordinate which becomes the new current point. In relative coordinates.
See https://www.w3.org/TR/SVG/paths.html#PathDataLinetoCommands
Args
x
- x-coordinate
y
- y-coordinate
Returns
The current Path
instance.
m
Start a new sub-path at the given (x,y) coordinates. In relative coordinates.
See https://www.w3.org/TR/SVG/paths.html#PathDataMovetoCommands
Args
x
- x-coordinate
y
- y-coordinate
Returns
The current Path
instance.
path
q
Draws a quadratic Bézier curve from the current point to (x,y) using (x1,y1) as the control point. In relative coordinates.
See https://www.w3.org/TR/SVG/paths.html#PathDataQuadraticBezierCommands
Args
x1
- x-coordinate of first control point
y1
- y-coordinate of first control point
x
- x-coordinate
y
- y-coordinate
Returns
The current Path
instance.
s
Draws a cubic Bézier curve from the current point to (x,y). The first control point is assumed to be the reflection of the second control point on the previous command relative to the current point. (x2,y2) is the second control point (i.e., the control point at the end of the curve). In relative coordinates.
See https://www.w3.org/TR/SVG/paths.html#PathDataCubicBezierCommands
Args
x2
- x-coordinate of second control point
y2
- y-coordinate of second control point
x
- x-coordinate
y
- y-coordinate
Returns
The current Path
instance.
t
Draws a quadratic Bézier curve from the current point to (x,y). The control point is assumed to be the reflection of the control point on the previous command relative to the current point. In relative coordinates.
See https://www.w3.org/TR/SVG/paths.html#PathDataQuadraticBezierCommands
Args
x
- x-coordinate
y
- y-coordinate
Returns
The current Path
instance.
v
Draws a vertical line from the current point. In relative coordinates.
See https://www.w3.org/TR/SVG/paths.html#PathDataLinetoCommands
Args
y
- y-coordinate
Returns
The current Path
instance.
z
Close the current subpath by connecting it back to the current subpath's initial point.
See https://www.w3.org/TR/SVG/paths.html#PathDataClosePathCommand
Returns
The current Path
instance.
Turtle
A Logo-like Turtle implementation for generating SVG paths. This is not a complete Turtle implementation. Contains a useful subset relevant to generating paths without using trigonometry or mental gymnastics.
Create a Turtle.
Args
x
- initial position x
y
- initial position y
degrees
- initial angle in degrees