[Cairo] Color transforms

Bill Spitzak spitzak at d2.com
Wed Jul 16 17:50:51 PDT 2003

On Wednesday 16 July 2003 11:20 am, Carl Worth wrote:

> On Jul 16, Bill Spitzak wrote:
>  > Curveto is then implemented portably by transforming the points,
>  > figuring out the subdivisions so the error is less than 1/4
>  > transformed pixel, and then calling the transformed interface with
>  > the resulting line segments.
> Actually, it's important to keep the curve as a curve, (rather than an
> approximation by line segments), until the stroke operation [*].
> Approximating the curve to within an error value is a very different
> thing than approximating the stroked outline to within the same error
> value. Many graphics systems get this wrong and the resulting errors
> can be visible with large line width and sharp curvature.

I had not thought about that (my library did not bother with drawing lines on 
paths other than to use the graphics system's pen).

Converting a path to a stroke outline is actually really complex and maybe 
should be in the device-independent portion. The device-dependent portion 
would only have a method to fill a fully-constructed and transformed path, 
and perhaps a "fast" line drawing for any line thicknesses less than 1. 
However this may have problems in that it may make it impossible to use some 
acceleration that the hardware may have.

> Someone familiar with the algorithm within Cairo might point out that
> the curve stroking algorithm actually does operate on a piecewise
> linear approximation of the curve. So the approximation could happen
> earlier. But the path data structure would have to maintain the
> distinction between linear segments belonging to curves vs. those
> belonging to true linear path segments so the joins could be handled
> differently. Come to think of it, for round joins no distinction is
> actually needed --- sounds like there's room for a minor optimization
> of round joins here.

This sounds like the problem can be solved by being able to indicate at each 
point what type of line-join is wanted. Perhaps this could be added to the 
interface instead? Then curveto could produce straight line segments with 
round joins. It also seems that would be useful for producing some shapes 
that GUI's want, for instance a rectangle with some square and some rounded 

PostScript seems to join the segments with whatever join type the user has 
selected. But it also has several other bugs, for instance round joins seem 
to be done by splatting a circle atop the intersection, which is visible if 
the lines are shorter than they are wide.

                   ,~,~,~,~ ~ ~ ~ ~
     /\_       _|_========___         Bill Spitzak
 ~~~/\/\\~~~~~~\____________/~~~~~~~~ spitzak at d2.com

More information about the cairo mailing list