[cairo] Simplifying the operator set

Carl Worth cworth at cworth.org
Fri Jan 7 11:31:56 PST 2005


On Fri, 7 Jan 2005 10:48:46 -0800, Bill Spitzak wrote:
> "DEST" is in fact a no-op, right? Maybe it should be eliminated too?

Yes. Good point. I missed that one.

> "DEST_OVER" can be called "UNDER" which might be easier to read.
> 
> I have seen "DEST_IN" called "MASK" and "DEST_OUT" called "STENCIL", but I 
> never thought of that as being too clear. However the user will probably see 
> these operators as "change an area in the dest to black" so "DEST_OUT" might 
> be called "ERASE". I can't think of anything better for "DEST_IN" than 
> "INVERSE_ERASE"

I think UNDER, ERASE, and INVERSE_ERASE are rather intuitive names. We
can define these in terms of the Porter/Duff Over, In, and Out
operators for those who are more familiar with those names.

> I'm not sure what "SATURATE" does, but there is a whole group of operators I 
> call the "photoshop operators". The common thing about them is that the alpha 
> is always a+b-ab. The colors are then various calculations to produce 
> photographic effects.

Do you know of a canonical definition for the calculations for these?
The PDF Reference manual has such a list, but some operators have only
vague descriptions in English. For example:

	"ColorDodge: Brightens the backdrop color to reflect the
	source color. Painting with black produces no change"

	"Exclusion: Produces an effect similar to that of the
	Difference mode, but lower in contrast. Painting with white
	inverts the backdrop color; painting with black produces no
	change."

> As far as I can tell, SVG requires a large set of these, and I see no way of 
> doing this correctly excepty by implementing them all in Cairo.

SVG 1.1 doesn't have them all as far as I can see, but the
work-in-progress SVG 1.2 does have a stated goal to include all the
PDF 1.4 operators. There's a page with equations and example figures
here:

	http://www.w3.org/TR/SVG12/rendering.html

which includes the caveat:

	"These equations are approximations which are under
	review. Final equations may differ from those presented here"

Oh, and I see that SVG does use the same naming convention I had
proposed yesterday, ("dst-over", "dst-out", etc.). Though it also has
the rather awkward names of "src-over", "src-out", etc.  I still think
I like the more descriptive names of "under" and "erase".

> You mentioned getting rid of "CLEAR", and I agree. However there does need to 
> be another drawing method along with fill and stroke, that ignores the path 
> and thus performs the composition operation to the entire area inside the 
> clip region. Though perhaps clearing the path and doing a fill with the 
> INVERSE type should do this.

An inverse fill with an empty path would certainly fill to the
clip. That may be sufficient, or we can add a new "erase" or "clear"
function. (I'm much more comfortable adding that now that we have a
definition for it in terms of fill, rather than being a truly unique
drawing operation).

-Carl




More information about the cairo mailing list