[cairo] Fill not overlapping stroke?

Stuart Axon stuaxo2 at yahoo.com
Fri Jun 4 13:56:36 PDT 2010


In the end I found an example in the cairo documentation (for guile not python, I always have trouble using google to find the python docs)

I made a change as I noticed using pushgroup/popgroup + paint seems to impose a performance penalty.  The end result is this:

            if fillcolor is not None and strokecolor is not None:
                # Draw onto intermediate surface so that stroke
                # does not overlay fill
                cairo_ctx.push_group()

                cairo_ctx.set_source_rgba(*fillcolor)
                cairo_ctx.fill_preserve()

                cairo_ctx.set_source_rgba(*strokecolor)
                cairo_ctx.set_operator(cairo.OPERATOR_SOURCE)
                cairo_ctx.set_line_width(strokewidth)
                cairo_ctx.stroke()
            
                cairo_ctx.pop_group_to_source ()
                cairo_ctx.paint ()
            elif fillcolor is not None:
                cairo_ctx.set_source_rgba(*fillcolor)
                cairo_ctx.fill()
            elif strokecolor is not None:
                cairo_ctx.set_source_rgba(*strokecolor)
                cairo_ctx.set_line_width(strokewidth)
                cairo_ctx.stroke()



      


More information about the cairo mailing list