Skip to content

Commit

Permalink
Used angle types
Browse files Browse the repository at this point in the history
  • Loading branch information
Lehonti committed Nov 8, 2024
1 parent aa38e05 commit 6a338df
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Pinta.Effects/Effects/FragmentEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,25 @@ private static ImmutableArray<PointI> RecalcPointOffsets (
DegreesAngle rotationDegrees,
int distance)
{
double pointStep = RadiansAngle.MAX_RADIANS / fragments;

RadiansAngle rotationRadians = rotationDegrees.ToRadians () - new RadiansAngle (Math.PI / 2);
RadiansAngle pointStep = new (RadiansAngle.MAX_RADIANS / fragments);
RadiansAngle rotationAngle = rotationDegrees.ToRadians () - new RadiansAngle (Math.PI / 2);

var pointOffsets = ImmutableArray.CreateBuilder<PointI> (fragments);
pointOffsets.Count = fragments;

for (int i = 0; i < fragments; i++) {
double currentRadians = rotationRadians.Radians + (pointStep * i);
RadiansAngle currentAngle = new (rotationAngle.Radians + (pointStep.Radians * i));
pointOffsets[i] = new PointI (
X: (int) Math.Round (distance * -Math.Sin (currentRadians), MidpointRounding.AwayFromZero),
Y: (int) Math.Round (distance * -Math.Cos (currentRadians), MidpointRounding.AwayFromZero));
X: (int) Math.Round (distance * -Math.Sin (currentAngle.Radians), MidpointRounding.AwayFromZero),
Y: (int) Math.Round (distance * -Math.Cos (currentAngle.Radians), MidpointRounding.AwayFromZero));
}

return pointOffsets.MoveToImmutable ();
}

public override void Render (ImageSurface src, ImageSurface dst, ReadOnlySpan<RectangleI> rois)
public override void Render (
ImageSurface src,
ImageSurface dst,
ReadOnlySpan<RectangleI> rois)
{
var pointOffsets = RecalcPointOffsets (
Data.Fragments,
Expand Down

0 comments on commit 6a338df

Please sign in to comment.