Skip to content

Annular Sector: rendering issue #4752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
swharden opened this issue Jan 28, 2025 · 4 comments · Fixed by #4744 · May be fixed by ScottPlot/ScottPlot.NET#52
Closed

Annular Sector: rendering issue #4752

swharden opened this issue Jan 28, 2025 · 4 comments · Fixed by #4744 · May be fixed by ScottPlot/ScottPlot.NET#52

Comments

@swharden
Copy link
Member

#4739 added some fantastic new drawing features, but this one is a tiny bit broken 😅

I'll ping @CoderPM2011 in case they want to take a closer look, but if we don't hear back before the next release (or they report they are busy) I am happy to take a closer look myself.

http://scottplot.net/cookbook/5.0/Shapes/AnnularSector/

Image

@swharden
Copy link
Member Author

private static SKPath GetEllipticalAnnularSector(PixelRect rect, PixelRect innerRect, float startAngle, float sweepAngle)
{
(Angle correctedStart, Angle correctedSweep) =
CorrectEllipseAngle(Angle.FromDegrees(startAngle), Angle.FromDegrees(sweepAngle), rect);
float start = (float)correctedStart.Degrees;
float sweep = (float)correctedSweep.Degrees;
static SKPoint GetPointOnEllipse(double centerX, double centerY, double a, double b, Angle theta)
{
double x = centerX + a * Math.Cos(theta.Radians);
double y = centerY + b * Math.Sin(theta.Radians);
return new((float)x, (float)y);
}
SKPoint p1 = GetPointOnEllipse(
innerRect.Center.X, innerRect.Center.Y,
innerRect.Right, innerRect.Bottom,
correctedStart + correctedSweep);
SKPoint p2 = GetPointOnEllipse(
rect.Center.X, rect.Center.Y, rect.Right, rect.Bottom, Angle.FromDegrees(0));
SKPath path = new();
path.AddArc(rect.ToSKRect(), start, sweep);
path.LineTo(p1);
path.AddArc(innerRect.ToSKRect(), start + sweep, -sweep);
path.LineTo(p2);
path.MoveTo(p2);
path.Close();
return path;
}

@CoderPM2011
Copy link
Contributor

Sorry for not replying directly
Actually PR #4744 has solved this problem.

@swharden
Copy link
Member Author

Oh wow, thanks for bringing that to my attention! I totally overlooked the PR but it looks like it solves this issue. You're awesome! Thanks again for all your hard work on this 🚀

@rotger
Copy link

rotger commented Apr 16, 2025

The cookbook images should be updated, hey still contain the bugged images for annular sectors: https://scottplot.net/cookbook/5.0/Shapes/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants