From: John H. <jdh...@ac...> - 2003-11-11 21:51:32
|
The GTK and wx backends have the same problem with pixel rounding on pcolor. I just cured it with GTK and I bet you can do the same for wx. The trick is to floor the positions and ceil the scales. This will make it much more likely that the left edge of one rectangle will align with the right edge of another. Eg, for the GTK backend def draw_rectangle(self, gc, filled, x, y, width, height): """ Draw a rectangle at lower left x,y with width and height If filled=True, fill the rectangle with the gc foreground gc is a GraphicsContext instance """ self.gdkDrawable.draw_rectangle( gc.gdkGC, filled, int(x), self.height-int(y+height), int(math.ceil(width)), int(math.ceil(height))) This worked great on my test code. Secondly, I am considering making a minor backend change for drawing 2D solids (arcs, rectangles, polygons) in the Renderer. Rather than calling the functions twice, once for edge and once for face, I would like to define them like def draw_rectangle(self, gcEdge, x, y, width, height, gcFace=None): that is, the gcFace takes the place of fill. If None, don't fill, otherwise fill with the gc in gcFace. This will avoid 2 function calls per patch (once on the patch.py end and once in the backend forwarding it to the underlying renderer, and will enable backends, eg, postscript, to take advantage of a native fill commands. For PS, this will at least halve the size of pcolor output files, which are currently obscenely large. Comments? JDH |