On Thu, 2012-05-17 at 23:53 +0200, Johan Engelen wrote:
On 8-5-2012 16:57, Tavmjong Bah wrote:
On Mon, 2012-05-07 at 23:37 -0700, Josh Andler wrote:
Replying from phone, sorry if short. Extrapolated would rock imho. The segment limit the lpe uses is quite frustrating though when getting creative, otherwise it's really awesome.
We just discussed this at the SVG Working Face-to-face meeting (I called in). There is support for adding the extrapolated version to the spec. Two small hiccups... one, a couple people asked for the exact mathematical formula to use to find the curvature of the last point (could you supply this?), and two, current rendering libraries that browsers use don't support this so it would have to be added (or simulated via a fill).
Nice to hear people are interested in powerstroke's feature that I am most proud of :-)
The extrapolation does not use the curvature of the path, but the path's direction instead. The direction of the path is then rotated 90 degrees to get the normal, which is then used to simply mirror the path itself to obtain the extrapolation. The direction is easily calculated from the derivative of the path (or 2nd derivative if 1st is zero, or 3rd if...); something like that must be already used to draw the standard SVG miter.
Ah, this explains why my first attempt at creating a demo image didn't look quite right and when I used circular arcs it looked better. When there is a large change in the rate of curvature along a path I don't think mirroring give's the best looking results. I think you want to keep the curvature constant or even the first and second derivatives constant (although the latter would be tougher to implement). When I get a chance, I'll create some tests.
A word of caution: my method of extrapolating might be harder computationally than necessary. This mirroring+intersection was the first thing that popped in my head (*) when thinking up the extrapolation concept, but perhaps there are other easier and just as visually pleasing methods. I do not know how normal strokes are rendered, and have no clue of what is feasible in terms of computational effort. One of the responses to my presentation at LGM was to try and use the curvature of the path and extrapolate with circles. I have not yet tried this...
(*) well, actually, my first idea was to just take the values of the bezier curve beyond its normal [0..1] domain. But I remember that this didn't really work very intuitively if at all.
So... how do other programs draw thick stroked lines? Surely, I am not the first to think of this.
Hmm, anybody with other drawing programs to check? It could be that the PostScript standard became the de facto standard for this.
Tav