[cairo] Radial shader transformation
Bill Spitzak
spitzak at d2.com
Mon Mar 1 17:30:51 PST 2004
On Monday 01 March 2004 03:12 pm, Thomas Hunger wrote:
> cairo_save
> rotate (Pi/2)
> setup_linear_shader ()
> cairo_restore
> rotate (PI/2)
> cairo_rectangle
> cairo_fill
>
> would rotate the gradient by PI so actually mirroring it. Is that what you
> mean?
Yes this is what I mean.
> So we would have two possibilities:
> 1) a set_shader() always sets up a normalized shader of "size" == 1.0 so
> the user has to transform it to make it fit to whatever position, size and
> orientation one wants. this has the advantage that the set_shader()
> functions would be simple to call. It has the disadvantage that the user
> has to have implicit knowledge about the shaders definition of normal. i.e.
> does the linear shader cover -0.5 to 0.5 or 0.0 to 1.0, ist it horizontal
> or vertical by default. stuff like that. though I think it would not be a
> big problem if documented.
>
> 2) a set_shader() takes shader-specific arguments (probably similar to the
> svg-arguments). It has the disadvantage of a bulky interface. On the
> positive side it is more intuitive since the user can do stuff like
> cairo_rectangle (0, 0, w, h);
> cairo_set_shader_linear (0, 0, w, 0);
> to make an exactly fitting shader without needing extra transforms.
>
> Both approaches seem ok to me. What do you think? (seems like you like the
> transform approach more, I just wanted to point out the issues I see with
> it)
I think 2 would be best: set_shader() call takes a *few* common arguments.
But does not have to take enough arguments to be able to replicate all
possible transforms, so it won't bloat. The documentation should clearly
state that the results of using a transform or the arguments is identical. My
big problem with some interfaces that offer multiple ways to do something is
that it often is not clear that the two results are the same, and I waste
great amounts of time adjusting one or the other trying to see which produces
the better result.
--
,~,~,~,~ ~ ~ ~ ~
/\_ _|_========___ Bill Spitzak
~~~/\/\\~~~~~~\____________/~~~~~~~~ spitzak at d2.com
More information about the cairo
mailing list