[cairo] status of dashed curve_to ?

John Ellson ellson at research.att.com
Wed Jun 1 14:34:49 PDT 2005


Carl Worth wrote:

>On Tue, 31 May 2005 14:48:59 -0400, John Ellson wrote:
>  
>
>>Are self-intersecting polylines dealt with now?
>>    
>>
>
>No, they are currently giving the wrong answer.
>
>I've just added a test (cairo/test/self-intersecting.c) to demonstrate
>the problem. Here's the blurb from the test:
>  
>
I just saw that in CVS and gave it a try.  Thanks. I see the problem now.

>>[*]  At the tolerance level of straight line segments approximating the 
>>bezier, why wouldn't miter joins
>>be sufficient?
>>    
>>
> <>
> Ah, this is the interesting part.
>
...

> <>The problem comes when stroking this approximation with a circular pen
> of finite width. The radius of the pen will result in greater errors
> at the stroke boundary than in the original approximation of the
> spline.

Understood.

>The solution that cairo has for this problem is the notion of the
>convolution of polygonal tracings[*] which Lyle Ramshaw guided us
>to. The idea is that a polygonal approximation of the pen can be
>convolved with the polygonal approximation of the path and yield the
>correct result. In effect, an arbitrarily accurate approximation to
>the composition of a quadratic and a cubic function can be found by a
>linear combination of linear approximations to each function.
>  
>

I think I understand.  I'll look up the reference.

Are you saying that cairo already has an implemetation of this?

>  * Round joins fall out automatically.
>
>But dashing does complicate things a bit.
>

Why not split the polyline into a list of polylines corresponding to 
each penned dash, *before* adding the pen width?

Then you would convert the segments to rectangular polygons (according 
to the pen width at the orientation of the segment).
Then for each n-segment polyline add n+1 end treatment polygons 
corresponding to: start/end caps, start/end dash-caps,  
bevel/miter/elliptical joins.  

Then merge all overlapping polygons and fill them.


John



More information about the cairo mailing list