Skip to content

Commit

Permalink
Use target type new
Browse files Browse the repository at this point in the history
  • Loading branch information
stefannikolei committed Jan 30, 2025
1 parent 085caa2 commit 9be1ec9
Show file tree
Hide file tree
Showing 624 changed files with 2,783 additions and 2,789 deletions.
4 changes: 2 additions & 2 deletions src/ImageSharp/Advanced/ParallelExecutionSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public ParallelExecutionSettings MultiplyMinimumPixelsPerTask(int multiplier)
{
Guard.MustBeGreaterThan(multiplier, 0, nameof(multiplier));

return new ParallelExecutionSettings(
return new(
this.MaxDegreeOfParallelism,
this.MinimumPixelsProcessedPerTask * multiplier,
this.MemoryAllocator);
Expand All @@ -92,6 +92,6 @@ public ParallelExecutionSettings MultiplyMinimumPixelsPerTask(int multiplier)
/// <returns>The <see cref="ParallelExecutionSettings"/>.</returns>
public static ParallelExecutionSettings FromConfiguration(Configuration configuration)
{
return new ParallelExecutionSettings(configuration.MaxDegreeOfParallelism, configuration.MemoryAllocator);
return new(configuration.MaxDegreeOfParallelism, configuration.MemoryAllocator);
}
}
2 changes: 1 addition & 1 deletion src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void Invoke(int i)
}

int yMax = Math.Min(yMin + this.stepY, this.maxY);
RowInterval rows = new RowInterval(yMin, yMax);
RowInterval rows = new(yMin, yMax);

// Skip the safety copy when invoking a potentially impure method on a readonly field
Unsafe.AsRef(in this.operation).Invoke(in rows);
Expand Down
4 changes: 2 additions & 2 deletions src/ImageSharp/Advanced/ParallelRowIterator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public static void IterateRows<T>(
}

int verticalStep = DivideCeil(rectangle.Height, numOfSteps);
ParallelOptions? parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps };
RowOperationWrapper<T> wrappingOperation = new RowOperationWrapper<T>(top, bottom, verticalStep, in operation);
ParallelOptions? parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps };
RowOperationWrapper<T> wrappingOperation = new(top, bottom, verticalStep, in operation);

Parallel.For(
0,
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/Color/Color.WebSafePalette.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp;
/// </content>
public partial struct Color
{
private static readonly Lazy<Color[]> WebSafePaletteLazy = new Lazy<Color[]>(CreateWebSafePalette, true);
private static readonly Lazy<Color[]> WebSafePaletteLazy = new(CreateWebSafePalette, true);

/// <summary>
/// Gets a collection of named, web safe colors as defined in the CSS Color Module Level 4.
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/Color/Color.WernerPalette.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp;
/// </content>
public partial struct Color
{
private static readonly Lazy<Color[]> WernerPaletteLazy = new Lazy<Color[]>(CreateWernerPalette, true);
private static readonly Lazy<Color[]> WernerPaletteLazy = new(CreateWernerPalette, true);

/// <summary>
/// Gets a collection of colors as defined in the original second edition of Werner’s Nomenclature of Colours 1821.
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/ColorProfiles/CieLab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static CieLab FromProfileConnectingSpace(ColorConversionOptions options,
float a = 500F * (fx - fy);
float b = 200F * (fy - fz);

return new CieLab(l, a, b);
return new(l, a, b);
}

/// <inheritdoc/>
Expand Down
6 changes: 3 additions & 3 deletions src/ImageSharp/ColorProfiles/CieLch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.ColorProfiles;
/// <param name="h">The hue in degrees.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieLch(float l, float c, float h)
: this(new Vector3(l, c, h))
: this(new(l, c, h))
{
}

Expand Down Expand Up @@ -101,7 +101,7 @@ public static CieLch FromProfileConnectingSpace(ColorConversionOptions options,
hDegrees += 360;
}

return new CieLch(l, c, hDegrees);
return new(l, c, hDegrees);
}

/// <inheritdoc/>
Expand All @@ -127,7 +127,7 @@ public CieLab ToProfileConnectingSpace(ColorConversionOptions options)
float a = c * MathF.Cos(hRadians);
float b = c * MathF.Sin(hRadians);

return new CieLab(l, a, b);
return new(l, a, b);
}

/// <inheritdoc/>
Expand Down
4 changes: 2 additions & 2 deletions src/ImageSharp/ColorProfiles/CieLchuv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.ColorProfiles;
/// <param name="h">The hue in degrees.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieLchuv(float l, float c, float h)
: this(new Vector3(l, c, h))
: this(new(l, c, h))
{
}

Expand Down Expand Up @@ -102,7 +102,7 @@ public static CieLchuv FromProfileConnectingSpace(ColorConversionOptions options
hDegrees += 360;
}

return new CieLchuv(l, c, hDegrees);
return new(l, c, hDegrees);
}

/// <inheritdoc/>
Expand Down
4 changes: 2 additions & 2 deletions src/ImageSharp/ColorProfiles/CieLuv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static CieLuv FromProfileConnectingSpace(ColorConversionOptions options,
v = 0;
}

return new CieLuv((float)l, (float)u, (float)v);
return new((float)l, (float)u, (float)v);
}

/// <inheritdoc/>
Expand Down Expand Up @@ -177,7 +177,7 @@ public CieXyz ToProfileConnectingSpace(ColorConversionOptions options)
z = 0;
}

return new CieXyz((float)x, (float)y, (float)z);
return new((float)x, (float)y, (float)z);
}

/// <inheritdoc/>
Expand Down
8 changes: 4 additions & 4 deletions src/ImageSharp/ColorProfiles/CieXyy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ public static CieXyy FromProfileConnectingSpace(ColorConversionOptions options,

if (float.IsNaN(x) || float.IsNaN(y))
{
return new CieXyy(0, 0, source.Y);
return new(0, 0, source.Y);
}

return new CieXyy(x, y, source.Y);
return new(x, y, source.Y);
}

/// <inheritdoc/>
Expand All @@ -113,14 +113,14 @@ public CieXyz ToProfileConnectingSpace(ColorConversionOptions options)
{
if (MathF.Abs(this.Y) < Constants.Epsilon)
{
return new CieXyz(0, 0, this.Yl);
return new(0, 0, this.Yl);
}

float x = (this.X * this.Yl) / this.Y;
float y = this.Yl;
float z = ((1 - this.X - this.Y) * y) / this.Y;

return new CieXyz(x, y, z);
return new(x, y, z);
}

/// <inheritdoc/>
Expand Down
6 changes: 3 additions & 3 deletions src/ImageSharp/ColorProfiles/Cmyk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.ColorProfiles;
/// <param name="k">The keyline black component.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Cmyk(float c, float m, float y, float k)
: this(new Vector4(c, m, y, k))
: this(new(c, m, y, k))
{
}

Expand Down Expand Up @@ -100,12 +100,12 @@ public static Cmyk FromProfileConnectingSpace(ColorConversionOptions options, in

if (MathF.Abs(k.X - 1F) < Constants.Epsilon)
{
return new Cmyk(0, 0, 0, 1F);
return new(0, 0, 0, 1F);
}

cmy = (cmy - k) / (Vector3.One - k);

return new Cmyk(cmy.X, cmy.Y, cmy.Z, k.X);
return new(cmy.X, cmy.Y, cmy.Z, k.X);
}

/// <inheritdoc/>
Expand Down
8 changes: 4 additions & 4 deletions src/ImageSharp/ColorProfiles/Hsl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.ColorProfiles;
/// <param name="l">The l value (lightness) component.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Hsl(float h, float s, float l)
: this(new Vector3(h, s, l))
: this(new(h, s, l))
{
}

Expand Down Expand Up @@ -99,7 +99,7 @@ public static Hsl FromProfileConnectingSpace(ColorConversionOptions options, in

if (MathF.Abs(chroma) < Constants.Epsilon)
{
return new Hsl(0F, s, l);
return new(0F, s, l);
}

if (MathF.Abs(r - max) < Constants.Epsilon)
Expand Down Expand Up @@ -130,7 +130,7 @@ public static Hsl FromProfileConnectingSpace(ColorConversionOptions options, in
s = chroma / (2F - max - min);
}

return new Hsl(h, s, l);
return new(h, s, l);
}

/// <inheritdoc/>
Expand Down Expand Up @@ -171,7 +171,7 @@ public Rgb ToProfileConnectingSpace(ColorConversionOptions options)
}
}

return new Rgb(r, g, b);
return new(r, g, b);
}

/// <inheritdoc/>
Expand Down
10 changes: 5 additions & 5 deletions src/ImageSharp/ColorProfiles/Hsv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.ColorProfiles;
/// <param name="v">The v value (brightness) component.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Hsv(float h, float s, float v)
: this(new Vector3(h, s, v))
: this(new(h, s, v))
{
}

Expand Down Expand Up @@ -97,7 +97,7 @@ public static Hsv FromProfileConnectingSpace(ColorConversionOptions options, in

if (MathF.Abs(chroma) < Constants.Epsilon)
{
return new Hsv(0, s, v);
return new(0, s, v);
}

if (MathF.Abs(r - max) < Constants.Epsilon)
Expand All @@ -121,7 +121,7 @@ public static Hsv FromProfileConnectingSpace(ColorConversionOptions options, in

s = chroma / v;

return new Hsv(h, s, v);
return new(h, s, v);
}

/// <inheritdoc/>
Expand All @@ -143,7 +143,7 @@ public Rgb ToProfileConnectingSpace(ColorConversionOptions options)

if (MathF.Abs(s) < Constants.Epsilon)
{
return new Rgb(v, v, v);
return new(v, v, v);
}

float h = (MathF.Abs(this.H - 360) < Constants.Epsilon) ? 0 : this.H / 60;
Expand Down Expand Up @@ -194,7 +194,7 @@ public Rgb ToProfileConnectingSpace(ColorConversionOptions options)
break;
}

return new Rgb(r, g, b);
return new(r, g, b);
}

/// <inheritdoc/>
Expand Down
4 changes: 2 additions & 2 deletions src/ImageSharp/ColorProfiles/HunterLab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static HunterLab FromProfileConnectingSpace(ColorConversionOptions option
b = 0;
}

return new HunterLab(l, a, b);
return new(l, a, b);
}

/// <inheritdoc/>
Expand Down Expand Up @@ -141,7 +141,7 @@ public CieXyz ToProfileConnectingSpace(ColorConversionOptions options)
float x = (((a / ka) * sqrtPow) + pow) * xn;
float z = (((b / kb) * sqrtPow) - pow) * (-zn);

return new CieXyz(x, y, z);
return new(x, y, z);
}

/// <inheritdoc/>
Expand Down
12 changes: 6 additions & 6 deletions src/ImageSharp/ColorProfiles/KnownChromaticAdaptationMatrices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static class KnownChromaticAdaptationMatrices
/// von Kries chromatic adaptation transform matrix (Hunt-Pointer-Estevez adjusted for D65)
/// </summary>
public static readonly Matrix4x4 VonKriesHPEAdjusted
= Matrix4x4.Transpose(new Matrix4x4
= Matrix4x4.Transpose(new()
{
M11 = 0.40024F,
M12 = 0.7076F,
Expand All @@ -42,7 +42,7 @@ public static readonly Matrix4x4 VonKriesHPEAdjusted
/// von Kries chromatic adaptation transform matrix (Hunt-Pointer-Estevez for equal energy)
/// </summary>
public static readonly Matrix4x4 VonKriesHPE
= Matrix4x4.Transpose(new Matrix4x4
= Matrix4x4.Transpose(new()
{
M11 = 0.3897F,
M12 = 0.6890F,
Expand All @@ -65,7 +65,7 @@ public static readonly Matrix4x4 VonKriesHPE
/// Bradford chromatic adaptation transform matrix (used in CMCCAT97)
/// </summary>
public static readonly Matrix4x4 Bradford
= Matrix4x4.Transpose(new Matrix4x4
= Matrix4x4.Transpose(new()
{
M11 = 0.8951F,
M12 = 0.2664F,
Expand All @@ -83,7 +83,7 @@ public static readonly Matrix4x4 Bradford
/// Spectral sharpening and the Bradford transform
/// </summary>
public static readonly Matrix4x4 BradfordSharp
= Matrix4x4.Transpose(new Matrix4x4
= Matrix4x4.Transpose(new()
{
M11 = 1.2694F,
M12 = -0.0988F,
Expand All @@ -101,7 +101,7 @@ public static readonly Matrix4x4 BradfordSharp
/// CMCCAT2000 (fitted from all available color data sets)
/// </summary>
public static readonly Matrix4x4 CMCCAT2000
= Matrix4x4.Transpose(new Matrix4x4
= Matrix4x4.Transpose(new()
{
M11 = 0.7982F,
M12 = 0.3389F,
Expand All @@ -119,7 +119,7 @@ public static readonly Matrix4x4 CMCCAT2000
/// CAT02 (optimized for minimizing CIELAB differences)
/// </summary>
public static readonly Matrix4x4 CAT02
= Matrix4x4.Transpose(new Matrix4x4
= Matrix4x4.Transpose(new()
{
M11 = 0.7328F,
M12 = 0.4296F,
Expand Down
Loading

0 comments on commit 9be1ec9

Please sign in to comment.