banded pcolor

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

John Hunter said:

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

[code snipped]

I'm sure you're right. I'll try it tomorrow.

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.

This seems very sensible. The changes required in backend_wx will be
minimal, and wx has a native fill (well, a brush...), so I can take
advantage of this. Halving the size of PS output is very worthwhile, and
it'll probably double the speed of pcolor on wx.

Regards

Jeremy

John Hunter wrote:

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

Comments?

Only one comment from me: make sure to leave a way for non-convex polygons. It should be possible to draw, for example, a 5 pointed star in which the fill shouldn't extend outside the edges.