views:

461

answers:

2

What's the best practice for drawing a closed, filled path where each line has a different stroke?

+3  A: 

Fill the complete path, then iterate on its elements to stroke one line segment for every lineto and closepath (see actual Quartz names here). Your applier function will need to keep track of the current point itself.

Of course, if any of the elements are curveto instead of lineto, you may be screwed, but try it anyway.

Peter Hosey
i'm screwed, paths contain curveto's :(
Claus Wahlers
You may not be screwed after all, the more I think about it. You should try it.
Peter Hosey
+1  A: 

Incidentally, if your intent is to make marching ants (a selection marquee), there's a much simpler way: Set the line dash, then fill and stroke as normal.

Peter Hosey
i would like to draw, for example, a red-filled rectangle with the north edge being 10px red, the east one 20px blue, the south one 1px green, and the west one 15px pink. this is just an example. lines may be curves too. (thanks for your answers btw, apprechiated)
Claus Wahlers