[cairo] Obtaining two parallel paths from a single curve

Simon Budig simon at budig.de
Tue Jul 29 07:43:30 PDT 2008


(sorry, this should go to the list as well)

archee at 126 (archee at 126.com) wrote:
> Simon Budig wrote:
> > *If* the two directions are always parallel you could draw a wide line
> > (maybe also using two strokes for an outline) plus a very thin line
> > indicating the separation between the two directions.
> 
> In this way, you can not draw each direction of the road in different colors 
> (for example, to present traffic condition on each direction). So I
> think, to draw these parallel curves, I need to do some mathematical
> calculation to get two different curves according to the following
> knowledge:

Yeah, true. You could try to creatively use clipping to solve that but
it might be nontrivial as well...

> http://xahlee.org/SpecialPlaneCurves_dir/Parallel_dir/parallel.html
> and
> http://en.wikipedia.org/wiki/Parallel_curve
 
If you're curious in digging into ths problem in detail - here is a
document describing one approach. It is a bit hard to read and the
example code is in postscript, but it should contain a solution:

    http://www.fho-emden.de/~hoffmann/bezier18122002.pdf

I hope this helps,
         Simon
-- 
              simon at budig.de              http://simon.budig.de/


More information about the cairo mailing list