[pygtk] Drawing point,rectangle etc over png using Cairo

A.T.Hofkamp a.t.hofkamp at tue.nl
Tue Dec 1 19:21:38 WST 2009


nipun batra wrote:
> Thanks
> This is my expose event function
> 
> def expose(self, widget, event):
> 
> cr = widget.window.cairo_create()
> cr.set_source_surface(self.surface, self.border, self.border)
> cr.paint()
> cr.set_source_rgb(0.5, 0, 0)
> 
> #cr.paint()
> cr.rectangle(int(var1)*10,int(var2)*10,5,5)
> cr.fill()
> 
> Here i am initially drawing the background image and over it i am drawing points.These come from two variables(global) which are updated every clock cycle.Now maintaining a list and plotting it would be tedious and not at all processor friendly.Could you elaborate a bit on the other technique.Using "dirty" regions.
> Thanks in advance
> 

I think compared to drawing an image, drawing a few points seems not relevant.

I never used regions, but the idea is to mark an area as 'dirty' (eg the area containing the new 
point). Then you will automatically get an expose event, with the area that must be redrawn 
(probably somewhere in the 'event' parameter).
You can skip drawing all points that are outside that area.


More information about the pygtk mailing list