[metapost] straight lines vs. curves (SVG)
Hartmut Henkel
hartmut_henkel at gmx.de
Sun Apr 26 10:21:52 CEST 2009
On Sun, 26 Apr 2009, Taco Hoekwater wrote:
> Mojca Miklavec wrote:
> > fill unitsquare xscaled 1200 yscaled 200; generates
> > <path d="M0 200C399.9939 200,800.0061 200,1200 200C1200
> > 133.33435,1200 66.66565,1200 0C800.0061 0,399.9939 0,0 0C0 66.66565,0
> > 133.33435,0 200Z" style="fill: rgb(0%,0%,0%);stroke: none;"></path>
> This is a faithful rendering of the internal paths:
> unitsquare is scaled to 1 pt, so the original path looked like this:
>
> (0,0)..controls (0.33333,0) and (0.66667,0)
> ..(1,0)..controls (1,0.33333) and (1,0.66667)
> ..(1,1)..controls (0.66667,1) and (0.33333,1)
> ..(0,1)..controls (0,0.66667) and (0,0.33333)
> ..cycle
metapost uses "in-channel signaling" for straightness by this 1/3 -- 2/3
heuristics. And 1/3 -- 2/3 is rather "odd" due to the number 3, that 1/2
-- 1/2 (or even 0 -- 1, why not?) for internal representation maybe
would serve better regarding rounding.
But wouldn't it make sense to have instead a separate "straight" flag
carried with all really straight path segments (point-to-point ones that
didn't get any control by the user)? Straight lines are so basic drawing
elements that maybe they should be handled as always "straight". And if
the user would get access to this flag one would still know if some line
after a few transforms was/is a really straight one.
> This is one of the areas where megapost will solve the problem
> eventually,
yes, but if it's just increasing the precision, the problem would occur
probably more seldomly (still requiring some threshold) yet in principle
stay the same (but getting even lower priority :-)
Regards, Hartmut
More information about the metapost
mailing list