API Reference

class glsvg.SVGDoc(filename, anchor_x=0, anchor_y=0, config=None)

An SVG image document.

Users should instantiate this object once for each SVG file they wish to render.

anchor_x

Where the document is anchored. Valid values are numerical, or ‘left’, ‘right’, ‘center’

anchor_y

Where the document is anchored. Valid values are numerical, or ‘top’, ‘bottom’, ‘center’

defs = None

Maps from id to path definition

draw(x, y, z=0, angle=0, scale=1)

Draws the SVG to screen.

Args:
x : float
The x-coordinate at which to draw.
y : float
The y-coordinate at which to draw.
z : float
The z-coordinate at which to draw. Defaults to 0. Note that z-ordering may not give expected results when transparency is used.
angle : float
The angle by which the image should be rotated (in degrees). Defaults to 0.
scale : float
The amount by which the image should be scaled, either as a float, or a tuple of two floats (xscale, yscale).
get_path_by_id(id)

Returns a path for the given id, or key error

get_path_ids()

Returns all the path ids

is_stencil_enabled()

Indicates if this svg document will use the stencil buffer for rendering

patterns = None

Maps from pattern id to pattern

render()

Render the SVG file without any display lists or transforms. Use draw instead.

class glsvg.SVGStyle(inherit_from=None)
fill = None

The internal color

fill_rule = None

How to determine the “insideness” of a point. Possible values are “nonzero” and “evenodd”. See mozilla documentation for more details: http://www.w3.org/TR/SVG/painting.html

from_element(element)

Read relevant attributes off XML element

opacity = None

Overall opacity (multiplied by other elements)

stroke = None

The color of the surrounding outline

stroke_dasharray = None

Controls the pattern of dashes and gaps used to stroke path. List of alternating dashes and gaps.

stroke_width = None

The width of the surrounding outline

class glsvg.SVGConfig

Configuration for how to render SVG objects, such as the amount of detail allowed for bezier curves and availability of the stencil buffer

allow_stencil = None

Whether or not stencilling is allowed

bezier_points = None

The number of line segments into which to subdivide Bezier splines.

circle_points = None

The number of line segments into which to subdivide circular and elliptic arcs.

has_framebuffer_objects = None

Whether or not framebuffer objects are allowed

stencil_bits = None

The number of stencil bits available

super_detailed()

Returns a much more detailed copy of this config

tolerance = None

The minimum distance at which neighboring points are merged

class glsvg.svg_path.SVGRenderableElement(svg, element, parent)
absolute_transform

Return this transform, multiplied by chain of parents

add_child(child)

Add a child to this element class (usually children register with parent)

children = None

Children elements

description = None

Optional element description. Useful for embedding metadata.

id = None

The id of the element

is_def = None

Is this element a definition?

is_pattern = None

Is this element a pattern?

parent = None

The parent element

style = None

The element style (possibly with inherited traits from parent style)

tag_type = None

XML tag this was originally.

title = None

Optional element title

transform = None

Element transforms

class glsvg.SVGPath(svg, element, parent)

Represents a single SVG path. This is usually a distinct shape with a fill pattern, an outline, or both.

bounding_box()

returns a tuple describing the bounding box:

(min_x, min_y, max_x, max_y)

on_render()

Render immediately to screen (no display list). Slow! Consider using SVG.draw(...) instead.

outline = None

The actual path elements, as a list of vertices

shape = None

The base shape. Possible values: path, rect, circle, ellipse, line, polygon, polyline

svg = None

The original SVG file

triangles = None

The triangles that comprise the inner fill

Previous topic

Intro

Next topic

Status

This Page