Method summary
- __init__(self)
- add_path(self, path)
- add_point_to_subpath(self, pt)
- arc(self, x, y, radius, start_angle, end_angle, cw = False)
- arc_to(self, x1, y1, x2, y2, radius)
- begin_page(self)
- begin_path(self)
- clear_clip_path(self)
- clear_rect(self)
- clear_subpath_points(self)
- clip(self)
- clip_to_rect(self, x, y, width, height)
- clip_to_rects(self)
- close_path(self, tag = None)
- concat_ctm(self, transform)
- curve_to(self, x_ctrl1, y_ctrl1, x_ctrl2, y_ctrl2, x_to, y_to)
- device_draw_rect(self, x, y, sx, sy, mode)
- device_get_full_text_extent(self, textstring)
- device_get_text_extent(self, textstring)
- device_prepare_device_ctm(self)
- device_show_text(self, text)
- device_transform_device_ctm(self, func, args)
- draw_image(self, img, rect = None)
- draw_path(self, mode = FILL_STROKE)
- draw_rect(self, rect, mode)
- draw_subpath(self, mode)
- end_page(self)
- eof_fill_path(self)
- even_odd_clip(self)
- fill_path(self)
- fill_rect(self)
- fill_rects(self)
- flush(self)
- from_agg_affine(self, aff)
- get_ctm(self)
- get_full_text_extent(self, textstring)
- get_path_bounding_box(self)
- get_path_current_point(self)
- get_subpath_points(self, debug = 0)
- get_text_extent(self, textstring)
- get_text_matrix(self)
- get_text_position(self)
- is_path_empty(self)
- line_set(self, starts, ends)
- line_to(self, x, y)
- lines(self, points)
- move_to(self, x, y)
- quad_curve_to(self, x_ctrl, y_ctrl, x_to, y_to)
- rect(self, x, y, sx, sy)
- rects(self, rects)
- restore_state(self)
- rotate_ctm(self, angle)
- save_state(self)
- scale_ctm(self, sx, sy)
- select_font(self, face_name, size = 12, style = 'regular', encoding = None)
- set_alpha(self, alpha)
- set_antialias(self, value)
- set_character_spacing(self, spacing)
- set_fill_color(self, color)
- set_flatness(self, flatness)
- set_font(self, font)
- set_font_size(self, size)
- set_line_cap(self, style)
- set_line_dash(self, pattern, phase = 0)
- set_line_join(self, style)
- set_line_width(self, width)
- set_miter_limit(self, limit)
- set_stroke_color(self, color)
- set_text_drawing_mode(self, mode)
- set_text_matrix(self, ttm)
- set_text_position(self, x, y)
- show_glyphs(self)
- show_glyphs_at_point(self)
- show_text(self, text)
- show_text_at_point(self, text, x, y)
- stroke_path(self)
- stroke_rect(self)
- stroke_rect_with_width(self)
- synchronize(self)
- translate_ctm(self, tx, ty)
Methods
- __init__(self)
- add_path(self, path)
Draw a compiled path into this gc. Note: if the CTM is changed and not restored to the identity in the compiled path, the CTM change will continue in this GC.
- add_point_to_subpath(self, pt)
- arc(self, x, y, radius, start_angle, end_angle, cw = False)
Draw a circular arc.
If there is a current path and the current point is not the initial point of the arc, a line will be drawn to the start of the arc. If there is no current path, then no line will be drawn.
Parameters
- x : float
- X-value of the center of the arc.
- y : float
- Y-value of the center of the arc.
- radius : float
- The radius of the arc.
- start_angle : float
- The angle, in radians, that the starting point makes with respect to the positive X-axis from the center point.
- end_angle : float
- The angles, in radians, that the final point makes with respect to the positive X-axis from the center point.
- cw : bool, optional
- Whether the arc should be drawn clockwise or not.
- arc_to(self, x1, y1, x2, y2, radius)
- begin_page(self)
Creates a new page within the graphics context.
Currently this is a NOP for all implementations. The PDF backend should probably implement it, but the ReportLab Canvas uses the showPage() method to handle both begin_page and end_page issues.
- begin_path(self)
Clears the current drawing path and begin a new one.
- clear_clip_path(self)
- clear_rect(self)
- clear_subpath_points(self)
- clip(self)
- clip_to_rect(self, x, y, width, height)
Sets the clipping path to the intersection of the current clipping path with the area defined by the specified rectangle
- clip_to_rects(self)
- close_path(self, tag = None)
Closes the path of the current subpath.
Currently starts a new subpath -- is this what we want?
- concat_ctm(self, transform)
Concatenates the transform to current coordinate transform matrix.
Parameters
- transform : affine_matrix
- the transform matrix to concatenate with the current coordinate matrix.
- curve_to(self, x_ctrl1, y_ctrl1, x_ctrl2, y_ctrl2, x_to, y_to)
Draw a cubic bezier curve from the current point.
Parameters
- x_ctrl1 : float
- X-value of the first control point.
- y_ctrl1 : float
- Y-value of the first control point.
- x_ctrl2 : float
- X-value of the second control point.
- y_ctrl2 : float
- Y-value of the second control point.
- x_to : float
- X-value of the ending point of the curve.
- y_to : float
- Y-value of the ending point of the curve.
- device_draw_rect(self, x, y, sx, sy, mode)
Default implementation of drawing a rect.
- device_get_full_text_extent(self, textstring)
- device_get_text_extent(self, textstring)
- device_prepare_device_ctm(self)
- device_show_text(self, text)
Draws text on the device at the current text position.
This relies on the FreeType engine to render the text to an array and then calls the device dependent device_show_text() to display the rendered image to the screen.
!! antiliasing is turned off until we get alpha blending !! of images figured out.
- device_transform_device_ctm(self, func, args)
Default implementation for handling scaling matrices.
Many implementations will just use this function. Others, like OpenGL, can benefit from overriding the method and using hardware acceleration.
- draw_image(self, img, rect = None)
- draw_path(self, mode = FILL_STROKE)
Walks through all the drawing subpaths and draw each element.
Each subpath is drawn separately.
Parameters
- mode
Specifies how the subpaths are drawn. The default is FILL_STROKE. The following are valid values.
- FILL
- Paint the path using the nonzero winding rule to determine the regions for painting.
- EOF_FILL
- Paint the path using the even-odd fill rule.
- STROKE
- Draw the outline of the path with the current width, end caps, etc settings.
- FILL_STROKE
- First fill the path using the nonzero winding rule, then stroke the path.
- EOF_FILL_STROKE
- First fill the path using the even-odd fill method, then stroke the path.
- draw_rect(self, rect, mode)
- draw_subpath(self, mode)
Fills and strokes the point path.
After the path is drawn, the subpath point list is cleared and ready for the next subpath.
Parameters
- mode
Specifies how the subpaths are drawn. The default is FILL_STROKE. The following are valid values.
- FILL
- Paint the path using the nonzero winding rule to determine the regions for painting.
- EOF_FILL
- Paint the path using the even-odd fill rule.
- STROKE
- Draw the outline of the path with the current width, end caps, etc settings.
- FILL_STROKE
- First fill the path using the nonzero winding rule, then stroke the path.
- EOF_FILL_STROKE
- First fill the path using the even-odd fill method, then stroke the path.
- Note:
- If path is closed, it is about 50% faster to call DrawPolygon with the correct pen set than it is to call DrawPolygon and DrawLines separately in wxPython. But, because paths can be left open, Polygon can't be called in the general case because it automatically closes the path. We might want a separate check in here and allow devices to specify a faster version if the path is closed.
- end_page(self)
Ends drawing in the current page of the graphics context.
Currently this is a NOP for all implementations. The PDF backend should probably implement it, but the ReportLab Canvas uses the showPage() method to handle both begin_page and end_page issues.
- eof_fill_path(self)
- even_odd_clip(self)
- fill_path(self)
- fill_rect(self)
- fill_rects(self)
- flush(self)
Sends all drawing data to the destination device.
Currently this is a NOP for wxPython.
- from_agg_affine(self, aff)
Convert an agg.AffineTransform to a numpy matrix representing the affine transform usable by kiva.affine and other non-agg parts of kiva
- get_ctm(self)
Returns the current coordinate transform matrix.
- get_full_text_extent(self, textstring)
Calls device specific text extent method.
- get_path_bounding_box(self)
- get_path_current_point(self)
Returns the current point from the graphics context.
- Note:
- Currently the current_point is only affected by move_to, line_to, and lines. It should also be affected by text operations. I'm not sure how rect and rects and friends should affect it -- will find out on Mac.
- get_subpath_points(self, debug = 0)
Gets the points that are in the current path.
The first entry in the draw_points list may actually be an array. If this is true, the other points are converted to an array and concatenated with the first
- get_text_extent(self, textstring)
Calls device specific text extent method.
- get_text_matrix(self)
- get_text_position(self)
- is_path_empty(self)
Tests to see whether the current drawing path is empty
- line_set(self, starts, ends)
Adds a set of disjoint lines as a new subpath.
Parameters
- starts
- an Nx2 array of x,y pairs
- ends
- an Nx2 array of x,y pairs
Starts and ends should have the same length. The current point is moved to the last point in 'ends'.
- line_to(self, x, y)
Adds a line from the current point to the given point (x,y).
The current point is moved to (x,y).
What should happen if move_to hasn't been called? Should it always begin at 0,0 or raise an error?
- Notes:
- See note in move_to about the current_point.
- lines(self, points)
Adds a series of lines as a new subpath.
Parameters
- points
- an Nx2 array of x,y pairs
The current_point is moved to the last point in 'points'
- move_to(self, x, y)
Starts a new drawing subpath and place the current point at (x,y).
- Notes:
- Not sure how to treat state.current_point. Should it be the value of the point before or after the matrix transformation? It looks like before in the PDF specs.
- quad_curve_to(self, x_ctrl, y_ctrl, x_to, y_to)
Draw a quadratic bezier curve from the current point.
Parameters
- x_ctrl : float
- X-value of the control point
- y_ctrl : float
- Y-value of the control point.
- x_to : float
- X-value of the ending point of the curve
- y_to : float
- Y-value of the ending point of the curve.
- rect(self, x, y, sx, sy)
Adds a rectangle as a new subpath.
- rects(self, rects)
Adds multiple rectangles as separate subpaths to the path.
Not very efficient -- calls rect multiple times.
- restore_state(self)
Restores the previous graphics state.
- rotate_ctm(self, angle)
Rotates the coordinate space for drawing by the given angle.
Parameters
- angle : float
- the angle, in radians, to rotate the coordinate system
- save_state(self)
Saves the current graphic's context state.
Always pair this with a restore_state().
- scale_ctm(self, sx, sy)
Sets the coordinate system scale to the given values, (sx,sy).
Parameters
- sx : float
- The new scale factor for the x axis
- sy : float
- The new scale factor for the y axis
- select_font(self, face_name, size = 12, style = 'regular', encoding = None)
Selects a new font for drawing text.
Parameters
- face_name
- The name of a font. E.g.: "Times New Roman" !! Need to specify a way to check for all the types size The font size in points.
- style
- One of "regular", "bold", "italic", "bold italic"
- encoding
A 4 letter encoding name. Common ones are:
- "unic" -- unicode
- "armn" -- apple roman
- "symb" -- symbol
Not all fonts support all encodings. If none is specified, fonts that have unicode encodings default to unicode. Symbol is the second choice. If neither are available, the encoding defaults to the first one returned in the FreeType charmap list for the font face.
- set_alpha(self, alpha)
- set_antialias(self, value)
Sets/Unsets anti-aliasing for bitmap graphics context.
Ignored on most platforms.
- set_character_spacing(self, spacing)
Sets the amount of additional spacing between text characters.
Parameters
- spacing : float
- units of space extra space to add between text coordinates. It is specified in text coordinate system.
Notes
- I'm assuming this is horizontal spacing?
- Not implemented in wxPython.
- set_fill_color(self, color)
set_fill_color takes a sequences of rgb or rgba values between 0.0 and 1.0
- set_flatness(self, flatness)
Not implemented
It is device dependent and therefore not recommended by the PDF documentation.
flatness determines how accurately lines are rendered. Setting it to values less than one will result in more accurate drawings, but they take longer. It defaults to None
- set_font(self, font)
Set the font for the current graphics context.
- set_font_size(self, size)
Sets the size of the font.
The size is specified in user space coordinates.
- Note:
- I don't think the units of this are really "user space coordinates" on most platforms. I haven't looked into the text drawing that much, so this stuff needs more attention.
- set_line_cap(self, style)
Specifies the style of endings to put on line ends.
Parameters
- style : cap_style
- The line cap style to use. Available styles are CAP_ROUND, CAP_BUTT, CAP_SQUARE.
- set_line_dash(self, pattern, phase = 0)
Sets the line dash pattern and phase for line painting.
Parameters
- pattern : float array
- An array of floating point values specifing the lengths of on/off painting pattern for lines.
- phase : float
- Specifies how many units into dash pattern to start. phase defaults to 0.
- set_line_join(self, style)
Sets the style for joining lines in a drawing.
Parameters
- style : join_style
- The line joining style. The available styles are JOIN_ROUND, JOIN_BEVEL, JOIN_MITER.
- set_line_width(self, width)
Sets the line width for drawing
Parameters
- width : float
- The new width for lines in user space units.
- set_miter_limit(self, limit)
Specifies limits on line lengths for mitering line joins.
If line_join is set to miter joins, the limit specifies which line joins should actually be mitered. If lines are not mitered, they are joined with a bevel. The line width is divided by the length of the miter. If the result is greater than the limit, the bevel style is used.
This is not implemented on most platforms.
Parameters
- limit : float
- limit for mitering joins. defaults to 1.0. (XXX is this the correct default?)
- set_stroke_color(self, color)
set_stroke_color takes a sequences of rgb or rgba values between 0.0 and 1.0
- set_text_drawing_mode(self, mode)
Specifies whether text is drawn filled or outlined or both.
Parameters
- mode
determines how text is drawn to the screen. If a CLIP flag is set, the font outline is added to the clipping path. Possible values:
- TEXT_FILL
- fill the text
- TEXT_STROKE
- paint the outline
- TEXT_FILL_STROKE
- fill and outline
- TEXT_INVISIBLE
- paint it invisibly ??
- TEXT_FILL_CLIP
- fill and add outline clipping path
- TEXT_STROKE_CLIP
- outline and add outline to clipping path
- TEXT_FILL_STROKE_CLIP
- fill, outline, and add to clipping path
- TEXT_CLIP
- add text outline to clipping path
- Note:
- wxPython currently ignores all but the INVISIBLE flag.
- set_text_matrix(self, ttm)
- set_text_position(self, x, y)
- show_glyphs(self)
- show_glyphs_at_point(self)
- show_text(self, text)
Draws text on the device at the current text position.
This calls the device dependent device_show_text() method to do all the heavy lifting.
It is not clear yet how this should affect the current point.
- show_text_at_point(self, text, x, y)
- stroke_path(self)
- stroke_rect(self)
- stroke_rect_with_width(self)
- synchronize(self)
Prepares drawing data to be updated on a destination device.
Currently this is a NOP for all implementations.
- translate_ctm(self, tx, ty)
Translates the coordinate system by the value given by (tx,ty)
Parameters
- tx : float
- The distance to move in the x direction
- ty : float
- The distance to move in the y direction