CoreGraphics Dashed Lines Bug #2(?)


These two images are the same path, stroked with dashes, drawn at different angles. Some of the corners render differently depending on the angle.
Compile the demonstration and drag the slider around for the full effect.
DashedLinesBug2.zip
10.5.2
2 Comments:
I'm not sure if you'll find this helpful, but I believe the problem is caused because CGContextAddArc is adding an extra "line-to" operation before adding the curve operation.
Here are the Quartz operations that you get for each segment:
150 0 m
150 0 l
150 53.589844 121.41016 103.10889 75 129.90381 c
37.5 64.951904 l
37.5 64.951904 l
60.705078 51.554443 75 26.794922 75 0 c
h
In case you're not familiar with PDF operators: m=move-to, l = line-to, c = curve-to (arcs are converted to bezier curve approximations), h = close path.
The culprit is the extra line-to operation. It's possible that it's created because of a rounding error. You might be able to workaround the problem by using CGContextAddArcToPoint instead but that would involve doing some calculations.
Thanks, that does appear to be the trigger and some sort of rounding error. It starts showing up when the coordinates are around 0.0001 apart and is more aggravated as they get closer. You can fiddle with this by changing
CGPointMake(outerRadius,0) to
CGPointMake(outerRadius-0.0001,0) or
CGPointMake(outerRadius-0.00001,0) or
0.0001 will show a tiny little blip, 0.00001 will be full scale blippage.
Post a Comment
<< Home