Example #1
0
 def __update_grid_surface(self, width, height, color = gtk.gdk.color_parse('#C0C0C0')):
     self._cached_grid_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
     ctx = cairo.Context(self._cached_grid_surface)        
     space = self._grid_size[self._grid_type]
     if space < 1: return
     x, y = 0,0
     position = x + space
     end = x + width
     ctx.save()
     set_context_color(ctx, color)
     ctx.set_line_width(1)
     position = x + space
     end = x + width
     while position < end:
         ctx.move_to(position, y)
         ctx.line_to(position, y + height)
         position += space
     position = y + space
     end = y + height
     while position < end:
         ctx.move_to(x, position )
         ctx.line_to(x + width, position)
         position += space
     ctx.stroke()
     ctx.restore()
Example #2
0
 def do_expose_event(self, event):
     x , y, width, height = event.area
     dimention = min(width,height)
     y += (height /2) - (dimention /2)
     width, height = dimention, dimention
     ctx = event.window.cairo_create()
     ctx.translate(x, y) 
     ctx.set_antialias(cairo.ANTIALIAS_SUBPIXEL)        
     ctx.rectangle(0, 0, width, height)
     ctx.clip_preserve()
     set_context_color(ctx, self._color)
     ctx.fill_preserve()
     ctx.set_line_width(1.0)
     set_context_color(ctx, gtk.gdk.color_parse('#000000'))
     ctx.stroke()
Example #3
0
 def draw(self, ctx, x=0, y=0):
     points = self._points
     if not points: return
     ctx.save()
     ctx.set_operator(self._operator)
     ctx.translate(x,y)
     x, y, width, height = self._path_rectangle
     ctx.rectangle(x,y, width, height)
     ctx.clip()
     ctx.set_antialias(cairo.ANTIALIAS_SUBPIXEL)   
     ctx.set_line_cap(cairo.LINE_CAP_ROUND)
     ctx.set_line_join(cairo.LINE_JOIN_ROUND)
     set_context_color(ctx, self._color)
     ctx.set_line_width(self._stroke_size)
     ctx.move_to(points[0].x, points[0].y)
     for point in points[1:len(points)]:
         ctx.line_to(point.x, point.y)
     if len(points) == 1:
         ctx.line_to(points[0].x, points[0].y)
     ctx.stroke()
     ctx.restore()
Example #4
0
 def __draw_canvas(self, ctx, x,y, width, height, color = gtk.gdk.color_parse('#ffffff')):
     ctx.save()
     set_context_color(ctx, color)
     ctx.set_operator(cairo.OPERATOR_DEST_OVER)
     ctx.paint()
     ctx.restore()