[cairo] Gradient mesh rasterizer

Bill Spitzak spitzak at gmail.com
Thu Jul 30 16:28:51 PDT 2009


It would seem this means there is no obvious solution if a stop is put 
in the middle of an edge. If any number of sides were allowed then the 
bezier could be split into two and that extra stop treated as another 
corner.

It would probably be best to make an api that more indicates that the 
colors are at the corners. A call to set the current color would work, 
it would apply to the current point. So you could move to a point, set 
the color, curveto another, set the color, etc. The older style stops 
could be done by moving in straight lines and not closing the path.

This will still allow closed paths with more than 4 points and allow 
open paths with the points not in a straight line, but it is closer to 
the set supported in that the colors are only at the points.

It also seems likely that user will want to draw these shapes directly 
rather than creating a surface. Cairo could support setting the color at 
each point in the actual path, as well. For back compatability if you 
set the color after building the path it will cause the next fill/stroke 
to act like that new color is constant over the entire path.

Adrian Johnson wrote:
> Bill Spitzak wrote:
>> Can the patch have any number of sides or is it required to have 4?
> 
> Internally patches are required to have 4 sides. Sides can be 
> degenerate. If less than 4 sides are specified cairo will fill in each 
> missing side with a cairo_pattern_line_to() to the first point in the 
> patch. See for example the mesh-gradient-conical test that draws a 
> conical gradient using circular sectors consisting of 2 lines and a 
> Bézier curve.
> 


More information about the cairo mailing list