Closed lostminds closed 3 months ago
I'm not entirely sure what you're saying here, but the logic of the code seems correct, and I did test this to see it forms the correct shape.
The start point is the left-most point on the circle (cx-r, cy)
Then it makes an arc the the right-most point (cx+r, cy)
Then a second arc right back.
The format for arc segments is [SEGMENT_TYPE.ARC, center+x_axis, center, center+y_axis, end]
with an implicit start
parameter taken from the previous segment.
The formula for it is center+x_axis*cos(alpha)+y_axis*sin(alpha)
where alpha
is monotonic rising (up to wrap-around at 360 degrees) from alpha_start
to alpha_end
, where x_axis*cos(alpha_start)+y_axis*sin(alpha_start)
is colinear to start-center
and x_axis*cos(alpha_end)+y_axis*sin(alpha_end)
is colinear to end-center
.
In the circle case, center+y_axis=end
for both arcs, while x_axis
is y-positive for the first arc, and y-negative for the second arc. This means both arcs go from -90 to 90 degrees, creating a full circle going x-negative, y-positive, x-positive, y-negative, and back to x-negative.
The format for arc segments is
[SEGMENT_TYPE.ARC, center+x_axis, center, center+y_axis, end]
with an implicitstart
parameter taken from the previous segment.
Ah, I see. Then it was just a case of me misunderstanding some of the points, thank you for the explanation.
In parse circle (and maybe the ellips version) https://github.com/SlugFiller/godot-vector2d/blob/bd7940f568aee89a133b6995bbc7bf17bb4eb251/addons/vector2d/svg.gd#L581
The circle element is parsed into a start and two arc segments for the shape path. I may be misunderstanding how these arcs are setup based on the four points for each arc, but it appears to me like they've got the wrong angles and coordinates around the circle. I would expect the start segment to be on the first arc start point and then the two arc 180°s to form the full circle. But instead the start is in another point and the two arcs seem to be 270°, causing overlapping shapes.