Skip to content

Commit

Permalink
Used compound assignments when appropriate (#618)
Browse files Browse the repository at this point in the history
* Used compound assignments when appropriate

* In `CairoExtensions`, swapped values using tuples
  • Loading branch information
Lehonti authored Dec 18, 2023
1 parent d56d348 commit 26d449d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Pinta.Core/Actions/ViewActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public void UpdateCanvasScale ()
return;

percent = Math.Min (percent, 3600);
percent = percent / 100.0;
percent /= 100.0;

PintaCore.Workspace.Scale = percent;
}
Expand Down
16 changes: 5 additions & 11 deletions Pinta.Core/Extensions/CairoExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -657,13 +657,13 @@ public static ColorBgra GetBilinearSampleWrapped (this ImageSurface src, ReadOnl
if (sx < 0)
sx = (srcWidth - 1) + ((sx + 1) % srcWidth);
else if (sx > (srcWidth - 1))
sx = sx % srcWidth;
sx %= srcWidth;

int sy = iv;
if (sy < 0)
sy = (srcHeight - 1) + ((sy + 1) % srcHeight);
else if (sy > (srcHeight - 1))
sy = sy % srcHeight;
sy %= srcHeight;

int sleft = sx;
int sright;
Expand Down Expand Up @@ -727,9 +727,7 @@ public static ImmutableArray<Scanline> GetScans (this ReadOnlySpan<PointI> point
int dy;

if (top.Y > bottom.Y) {
PointI temp = top;
top = bottom;
bottom = temp;
(bottom, top) = (top, bottom);
}

dy = bottom.Y - top.Y;
Expand All @@ -750,9 +748,7 @@ public static ImmutableArray<Scanline> GetScans (this ReadOnlySpan<PointI> point
min = j;

if (min != i) {
Edge temp = edgeTable[min];
edgeTable[min] = edgeTable[i];
edgeTable[i] = temp;
(edgeTable[i], edgeTable[min]) = (edgeTable[min], edgeTable[i]);
}
}

Expand Down Expand Up @@ -824,9 +820,7 @@ public static ImmutableArray<Scanline> GetScans (this ReadOnlySpan<PointI> point
min = j;

if (min != i) {
int temp = active[min];
active[min] = active[i];
active[i] = temp;
(active[i], active[min]) = (active[min], active[i]);
}
}

Expand Down
4 changes: 2 additions & 2 deletions Pinta.Effects/Effects/BulgeEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public override void Render (ImageSurface src, ImageSurface dst, ReadOnlySpan<Re
float maxrad = Math.Min (hw, hh);
float amt = bulge / 100f;

hh = hh + (float) Data.Offset.Y * hh;
hw = hw + (float) Data.Offset.X * hw;
hh += (float) Data.Offset.Y * hh;
hw += (float) Data.Offset.X * hw;

int src_width = src.Width;
int src_height = src.Height;
Expand Down
3 changes: 3 additions & 0 deletions Pinta.Tools/Brushes/CircleBrush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,16 @@ protected override RectangleI OnMouseMove (
BrushStrokeArgs strokeArgs)
{
PointI mouseDelta = strokeArgs.CurrentPosition - strokeArgs.LastPosition;

PointD center = new (
X: Math.Floor (strokeArgs.CurrentPosition.X / 100.0) * 100 + 50,
Y: Math.Floor (strokeArgs.CurrentPosition.Y / 100.0) * 100 + 50
);

double d = mouseDelta.Magnitude () * 2.0;
int steps = Random.Next (1, 10);
double step_delta = d / steps;

for (int i = 0; i < steps; i++) {
var radius = (steps - i) * step_delta;
g.Arc (center.X, center.Y, radius, 0, Math.PI * 2);
Expand Down

0 comments on commit 26d449d

Please sign in to comment.