Package gaphas :: Module util

Module util

source code

Helper funtions and classes for Cairo (drawing engine used by the canvas).

Version: $Revision: 1732 $

Functions
 
text_extents(cr, text, font=None, multiline=False, padding=1)
Simple way to determine the size of a piece of text.
source code
 
text_center(cr, x, y, text) source code
 
text_align(cr, x, y, text, align_x=0, align_y=0, padding_x=0, padding_y=0)
Draw text relative to (x, y).
source code
 
text_multiline(cr, x, y, text, padding=1)
Draw a string of text with embedded newlines.
source code
 
text_set_font(cr, font)
Set the font from a string.
source code
 
path_ellipse(cr, x, y, width, height, angle=0)
Draw an ellipse.
source code
Function Details

text_align(cr, x, y, text, align_x=0, align_y=0, padding_x=0, padding_y=0)

source code 
Draw text relative to (x, y). x, y - coordinates text - text to print (utf8) align_x - -1 (top), 0 (middle), 1 (bottom) align_y - -1 (left), 0 (center), 1 (right) padding_x - padding (extra offset), always > 0 padding_y - padding (extra offset), always > 0

text_multiline(cr, x, y, text, padding=1)

source code 
Draw a string of text with embedded newlines. cr - cairo context x - leftmost x y - topmost y text - text to draw padding - additional padding between lines.

text_set_font(cr, font)

source code 
Set the font from a string. E.g. 'sans 10' or 'sans italic bold 12' only restriction is that the font name should be the first option and the font size as last argument

path_ellipse(cr, x, y, width, height, angle=0)

source code 
Draw an ellipse. x - center x y - center y width - width of ellipse (in x direction when angle=0) height - height of ellipse (in y direction when angle=0) angle - angle in radians to rotate, clockwise