[cairo] Radial shader transformation
info at teh-web.de
Mon Mar 1 13:32:27 PST 2004
> I may be wrong, perhaps the current transform applies to the current
Hm. I thought quite a bit about that and came the the result that the current
transform should apply to the current shader.
I.e. if you do create horizontal, linear gradient via shader_linear (0,y,1,y)
and then call rotate(PI/2) the gradient would rotate together with the shape.
Did I understand you rightly that in your proposal the gradient would not
rotate, since it would use the transform frozen at its creation time?
> Certainly in my experience the fastest way to do an elliptical shader is to
> do a 2x3 matrix transform of the actual coordinate to map it to a 1-radius
> circle around 0,0 and then figure out the color from there. So specifying
> it this way with an arbitrary transform will not limit the implementation
> at all.
> Of course if this is true, there is no requirement to provide a radius, or
> even an x,y center point, to the radial shader. It can actually draw a
> 1-radius circle around 0,0 and the user must use transformations to put it
> in the correct place.
While it would be nice to have a shorter linear_shader_create function, this
would mean that before every stroke and fill the shader hast to be
transformed to the right place. That means every shading is bound to exactly
one stroke or fill operation.
A "general" shader that transforms with the current transform could be reused
for many strokes and fills. That would also work nicely with svg, although
svg allows an additional transform to shaders similar to the
set_surface_matrix for surfaces which could be introduced into the same model
without much hassle.
If we introduce a set_shader_matrix analougeous to the set_surface_matrix then
the rx and ry would not be needed any more, but xc, yc, fx, and fy would
still have to stay.
The rx and ry could still be used for convenience internally, since they need
to be calculated for the software shader anyway.
Btw. a nice link for the radial software shader if anyone is interested:
More information about the cairo