[cairo] Re: Filling and stroking an object with different color/alpha
cworth at cworth.org
Tue May 2 12:10:07 PDT 2006
On Tue, 2 May 2006 14:11:12 -0400, Adam Jackson wrote:
> Just for reference, OpenVG can do fill and stroke in one step.
Ah, interesting. That's something that did not exist (at least not in
any public form) when we did this part of cairo's design.
> The fundamental color source type is called a VGPaint, which corresponds roughly
> to a Picture in Render now that we have solid and gradient pictures.
So that sounds like what cairo calls a "pattern", (or more
> vgSetParameteri(fill_paint, VG_PAINT_TYPE, VG_PAINT_TYPE_PATTERN);
> vgPaintPattern(fill_paint, fill_image);
> vgSetParameteri(stroke_paint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
> vgSetParameterfv(stroke_paint, VG_PAINT_COLOR, 4, stroke_color);
> It is, of course, fully orthogonal; the stroke paint can be a pattern, etc.
> The important distinction, relative to cairo, is that it's a different answer
> to the zero-one-infinity rule. Rather than only allowing one instance of
> paint state per context, paints are promoted to objects, you may have any
> number of them, and you bind them into the context as you need them.
I'm not sure I follow this part. In cairo, patterns are an object, and
you may have any number of them.
The difference I see is that within the cairo graphics state, we allow
only a single source pattern:
cairo_set_source (cr, source);
while your example above shows two different places that a VGPaint can
be lodged into the state there, (both stroke_paint and fill_paint).
And it's that duplicity that I intentionally chose to avoid in
cairo--- zero-one-infinity, right?. Though I suppose that OpenVG does
actually allow an infinite number of slots for other ways to use paint
in extensions, (while only two slots that are used in the base layer).
> Introducing this concept into cairo now while still preserving the push_group
> semantics would be a bit awkward.
I think we have this already with all of the various cairo_pattern
APIs. What was probably misleading is my use of cairo_pop_group_to_source
above which was just a convenience for avoiding having to have a
temporary cairo_pattern_t pointer, (similar to cairo_set_source_rgb).
But there are plenty of ways to create patterns and hold on to as many
as you'd like:
> But then I actually like the GL API style, so I've probably already discounted
> myself from the discussion.
Oh, I'm pretty forgiving about mistakes like that. :-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060502/a0477d18/attachment.pgp
More information about the cairo