kiva.graphics_state module

GraphicsState Class

The GraphicsState class is used Kiva backends which need to have their state tracked by Python, rather than by an internal graphics state (eg. Wx, SVG and PDF backends, but not Agg or QPainter).

class kiva.graphics_state.GraphicsState[source]

Bases: kiva.line_state.LineState

Holds information used by a graphics context when drawing.

I’m not sure if these should be a separate class, a dictionary, or part of the GraphicsContext object. Making them a dictionary or object simplifies save_state and restore_state a little bit.

Also, this is a pretty good candidate for using slots. I’m not going to use them right now, but, if we standardize on 2.2, slots might speed things up some.

ctm

context transform matrix

fill_color

RGBA array(4) of values 0.0 to 1.0

alpha

transparency value of drawn objects

font

either a special device independent font object (what does anygui use?) or a device dependent font object.

text_matrix

coordinate transformation matrix for text

clipping_path

defines the path of the clipping region. For now, this can only be a rectangle.

current_point

location where next object is drawn.

should_antialias

whether anti-aliasing should be used when drawing lines and fonts

miter_limit

specifies when and when not to miter line joins.

flatness

specifies tolerance for bumpiness of curves

character_spacing

spacing between drawing text characters

text_drawing_mode

style for drawing text: outline, fill, etc.

These are inherited from LineState
line_color

RGBA array(4) of values 0.0 to 1.0

line_width

width of drawn lines

line_join

style of how lines are joined. The choices are: JOIN_ROUND, JOIN_BEVEL, JOIN_MITER

line_cap

style of the end cap on lines. The choices are: CAP_ROUND, CAP_SQUARE, CAP_BUTT

line_dash

(phase,pattern) dash pattern for lines. phase is a single value specifying how many units into the pattern to start. dash is a 1-D array of floats that alternate between specifying the number of units on and off in the pattern. When the end of the array is reached, the pattern repeats.

Not yet supported
rendering_intent

deals with colors and color correction in a sophisticated way.

copy()[source]

Makes a copy of the current line state