Package dtk :: Package ui :: Module draw

Module draw

source code

Functions
 
draw_radial_ring(cr, x, y, outer_radius, inner_radius, color_infos)
Draw radial ring.
source code
 
get_desktop_pixbuf()
Get screenshot of desktop.
source code
 
draw_round_rectangle(cr, x, y, width, height, r)
Draw round rectangle.
source code
 
draw_pixbuf(cr, pixbuf, x=0, y=0, alpha=1.0)
Draw pixbuf on cairo context, this function use frequently for image render.
source code
 
draw_window_frame(cr, x, y, w, h, color_frame_outside_1, color_frame_outside_2, color_frame_outside_3, color_frame_inside_1, color_frame_inside_2)
Draw window frame.
source code
 
draw_window_rectangle(cr, sx, sy, ex, ey, r)
Draw window rectangle.
source code
 
draw_text(cr, markup, x, y, w, h, text_size=DEFAULT_FONT_SIZE, text_color="#000000", text_font=DEFAULT_FONT, alignment=pango.ALIGN_LEFT, gaussian_radious=None, gaussian_color=None, border_radious=None, border_color=None, wrap_width=None)
Standard function for draw text.
source code
 
render_text(cr, markup, x, y, w, h, text_size=DEFAULT_FONT_SIZE, text_color="#000000", text_font=DEFAULT_FONT, alignment=pango.ALIGN_LEFT, wrap_width=None)
Render text for function draw_text, you can use this function individually.
source code
 
draw_line(cr, sx, sy, ex, ey, line_width=1, antialias_status=cairo.ANTIALIAS_NONE)
Draw line.
source code
 
draw_vlinear(cr, x, y, w, h, color_infos, radius=0, top_to_bottom=True)
Draw linear area vertically.
source code
 
draw_hlinear(cr, x, y, w, h, color_infos, radius=0, left_to_right=True)
Draw linear area horticulturally.
source code
 
expose_linear_background(widget, event, color_infos)
Expose linear background.
source code
 
draw_window_shadow(cr, x, y, w, h, r, p, color_window_shadow)
Draw window shadow.
source code
 
draw_radial_round(cr, x, y, r, color_infos)
Draw radial round.
source code
 
draw_blank_mask(cr, x, y, w, h)
Draw blank mask, use for default mask function.
source code
Function Details

draw_radial_ring(cr, x, y, outer_radius, inner_radius, color_infos)

source code 

Draw radial ring.

Parameters:
  • cr - Cairo context.
  • x - X coordinate of draw area.
  • y - Y coordinate of draw area.
  • outer_radius - Radious for outter ring.
  • inner_radius - Radious for inner ring.
  • color_infos - A list of ColorInfo, ColorInfo format as [(color_pos, (color_hex_value, color_alpha))].

get_desktop_pixbuf()

source code 

Get screenshot of desktop.

Returns:
Return desktop screenshot as gtk.gdk.Pixbuf.

draw_round_rectangle(cr, x, y, width, height, r)

source code 

Draw round rectangle.

Parameters:
  • cr - Cairo context.
  • x - X coordiante of rectangle area.
  • y - Y coordiante of rectangle area.
  • width - Width of rectangle area.
  • height - Width of rectangle area.
  • r - Radious of rectangle corner.

draw_pixbuf(cr, pixbuf, x=0, y=0, alpha=1.0)

source code 

Draw pixbuf on cairo context, this function use frequently for image render.

Parameters:
  • cr - Cairo context.
  • pixbuf - gtk.gdk.Pixbuf
  • x - X coordiante of draw area.
  • y - Y coordiante of draw area.
  • alpha - Alpha value to render pixbuf, float value between 0 and 1.0

draw_window_frame(cr, x, y, w, h, color_frame_outside_1, color_frame_outside_2, color_frame_outside_3, color_frame_inside_1, color_frame_inside_2)

source code 

Draw window frame.

Parameters:
  • cr - Cairo context.
  • x - X coordiante of draw area.
  • y - Y coordiante of draw area.
  • w - Width of draw area.
  • h - Height of draw area.
  • color_frame_outside_1 - Use for draw outside 8 points.
  • color_frame_outside_2 - Use for draw middle 4 points.
  • color_frame_outside_3 - Use for draw inside 4 points.
  • color_frame_inside_1 - Use for draw outside frame.
  • color_frame_inside_2 - Use for draw inner frame and inside 4 points.

draw_window_rectangle(cr, sx, sy, ex, ey, r)

source code 

Draw window rectangle.

Parameters:
  • cr - Cairo context.
  • sx - Source x coordinate.
  • sy - Source y coordinate.
  • ex - Target x coordinate.
  • ey - Target x coordinate.
  • r - Window frame radious.

draw_text(cr, markup, x, y, w, h, text_size=DEFAULT_FONT_SIZE, text_color="#000000", text_font=DEFAULT_FONT, alignment=pango.ALIGN_LEFT, gaussian_radious=None, gaussian_color=None, border_radious=None, border_color=None, wrap_width=None)

source code 

Standard function for draw text.

Parameters:
  • cr - Cairo context.
  • markup - Pango markup string.
  • x - X coordinate of draw area.
  • y - Y coordinate of draw area.
  • w - Width of draw area.
  • h - Height of draw area.
  • text_size - Text size, default is DEFAULT_FONT_SIZE.
  • text_color - Text color, default is "#000000".
  • text_font - Text font, default is DEFAULT_FONT.
  • alignment - Font alignment option, default is pango.ALIGN_LEFT. You can set pango.ALIGN_MIDDLE or pango.ALIGN_RIGHT.
  • gaussian_radious - Gaussian radious, default is None.
  • gaussian_color - Gaussian color, default is None.
  • border_radious - Border radious, default is None.
  • border_color - Border color, default is None.
  • wrap_width - Wrap width of text, default is None.

render_text(cr, markup, x, y, w, h, text_size=DEFAULT_FONT_SIZE, text_color="#000000", text_font=DEFAULT_FONT, alignment=pango.ALIGN_LEFT, wrap_width=None)

source code 

Render text for function draw_text, you can use this function individually.

Parameters:
  • cr - Cairo context.
  • markup - Pango markup string.
  • x - X coordinate of draw area.
  • y - Y coordinate of draw area.
  • w - Width of draw area.
  • h - Height of draw area.
  • text_size - Text size, default is DEFAULT_FONT_SIZE.
  • text_color - Text color, default is "#000000".
  • text_font - Text font, default is DEFAULT_FONT.
  • alignment - Font alignment option, default is pango.ALIGN_LEFT. You can set pango.ALIGN_MIDDLE or pango.ALIGN_RIGHT.
  • wrap_width - Wrap width of text, default is None.

draw_line(cr, sx, sy, ex, ey, line_width=1, antialias_status=cairo.ANTIALIAS_NONE)

source code 

Draw line.

Parameters:
  • cr - Cairo context.
  • sx - Souce X coordinate.
  • sy - Souce Y coordinate.
  • ex - Target X coordinate.
  • ey - Target Y coordinate.
  • line_width - Line width, default is 1 pixel.
  • antialias_status - Antialias status, default is cairo.ANTIALITAS_NONE.

draw_vlinear(cr, x, y, w, h, color_infos, radius=0, top_to_bottom=True)

source code 

Draw linear area vertically.

Parameters:
  • cr - Cairo context.
  • x - X coordinate of draw area.
  • y - Y coordinate of draw area.
  • w - Width of draw area.
  • h - Height of draw area.
  • color_infos - A list of ColorInfo, ColorInfo format: (color_stop_position, (color_hex_value, color_alpha))
  • radius - Rectangle corner radious.
  • top_to_bottom - Draw direction, default is from top to bottom, function will draw from bottom to top if set option as False.

draw_hlinear(cr, x, y, w, h, color_infos, radius=0, left_to_right=True)

source code 

Draw linear area horticulturally.

Parameters:
  • cr - Cairo context.
  • x - X coordinate of draw area.
  • y - Y coordinate of draw area.
  • w - Width of draw area.
  • h - Height of draw area.
  • color_infos - A list of ColorInfo, ColorInfo format: (color_stop_position, (color_hex_value, color_alpha))
  • radius - Rectangle corner radious.
  • left_to_right - Draw direction, default is from left to right, function will draw from right to left if set option as False.

expose_linear_background(widget, event, color_infos)

source code 

Expose linear background.

Parameters:
  • widget - Gtk.Widget instance.
  • event - Expose event.
  • color_infos - A list of ColorInfo, ColorInfo format: (color_stop_position, (color_hex_value, color_alpha))

draw_window_shadow(cr, x, y, w, h, r, p, color_window_shadow)

source code 

Draw window shadow.

Parameters:
  • cr - Cairo context.
  • x - X coordinate of draw area.
  • y - Y coordinate of draw area.
  • w - Width of draw area.
  • h - Height of draw area.
  • r - Radious of window shadow corner.
  • p - Padding between window shadow and window frame.
  • color_window_shadow - theme.DyanmicShadowColor.

draw_radial_round(cr, x, y, r, color_infos)

source code 

Draw radial round.

Parameters:
  • cr - Cairo context.
  • x - X coordinate of draw area.
  • y - Y coordinate of draw area.
  • r - Radious of radial round.
  • color_infos - A list of ColorInfo, ColorInfo format: (color_stop_position, (color_hex_value, color_alpha))

draw_blank_mask(cr, x, y, w, h)

source code 

Draw blank mask, use for default mask function.

Parameters:
  • cr - Cairo context.
  • x - X coordiante of rectangle area.
  • y - Y coordiante of rectangle area.
  • w - Width of rectangle area.
  • h - Width of rectangle area.