[cairo] Simplifying the operator set
Bill Spitzak
spitzak at d2.com
Fri Jan 7 10:48:46 PST 2005
On Thursday 06 January 2005 10:45 pm, Carl Worth wrote:
> typedef enum cairo_operator {
> CAIRO_OPERATOR_SOURCE
> CAIRO_OPERATOR_OVER,
> CAIRO_OPERATOR_IN,
> CAIRO_OPERATOR_OUT,
>
> CAIRO_OPERATOR_DEST,
> CAIRO_OPERATOR_DEST_OVER,
> CAIRO_OPERATOR_DEST_IN,
> CAIRO_OPERATOR_DEST_OUT,
>
> CAIRO_OPERATOR_ADD,
> CAIRO_OPERATOR_SATURATE
> } cairo_operator_t;
I think this is very much the right approach. Main comments are:
"DEST" is in fact a no-op, right? Maybe it should be eliminated too?
"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"
"ADD" is really an addition. The alphas have to be added together. It is a
unique operation in that it is the only one that needs to clamp it's output
even if the inputs are clamped. This is in fact an entire subset of it's own.
A useful operator we call "SCRN" (but some other software calls "UNION") is to
do A+B-AB for all the channels. This looks a lot like a double exposure on a
gamma 2.2 display.
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. Technically "OVER" and "SCRN" fall into this catagory.
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.
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.
--
,~,~,~,~ ~ ~ ~ ~
/\_ _|_========___ Bill Spitzak
~~~/\/\\~~~~~~\____________/~~~~~~~~ spitzak at d2.com
More information about the cairo
mailing list