diff --git a/src/ImageSharp/Common/Extensions/ComparableExtensions.cs b/src/ImageSharp/Common/Extensions/ComparableExtensions.cs deleted file mode 100644 index ef3d1deac..000000000 --- a/src/ImageSharp/Common/Extensions/ComparableExtensions.cs +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Runtime.CompilerServices; - -namespace SixLabors.ImageSharp -{ - /// - /// Extension methods for classes that implement . - /// - internal static class ComparableExtensions - { - /// - /// Restricts a to be within a specified range. - /// - /// The value to clamp. - /// The minimum value. If value is less than min, min will be returned. - /// The maximum value. If value is greater than max, max will be returned. - /// - /// The representing the clamped value. - /// - [MethodImpl(InliningOptions.ShortMethod)] - public static byte Clamp(this byte value, byte min, byte max) - { - // Order is important here as someone might set min to higher than max. - if (value >= max) - { - return max; - } - - if (value <= min) - { - return min; - } - - return value; - } - - /// - /// Restricts a to be within a specified range. - /// - /// The The value to clamp. - /// The minimum value. If value is less than min, min will be returned. - /// The maximum value. If value is greater than max, max will be returned. - /// - /// The representing the clamped value. - /// - [MethodImpl(InliningOptions.ShortMethod)] - public static uint Clamp(this uint value, uint min, uint max) - { - if (value >= max) - { - return max; - } - - if (value <= min) - { - return min; - } - - return value; - } - - /// - /// Restricts a to be within a specified range. - /// - /// The The value to clamp. - /// The minimum value. If value is less than min, min will be returned. - /// The maximum value. If value is greater than max, max will be returned. - /// - /// The representing the clamped value. - /// - [MethodImpl(InliningOptions.ShortMethod)] - public static int Clamp(this int value, int min, int max) - { - if (value >= max) - { - return max; - } - - if (value <= min) - { - return min; - } - - return value; - } - - /// - /// Restricts a to be within a specified range. - /// - /// The The value to clamp. - /// The minimum value. If value is less than min, min will be returned. - /// The maximum value. If value is greater than max, max will be returned. - /// - /// The representing the clamped value. - /// - [MethodImpl(InliningOptions.ShortMethod)] - public static float Clamp(this float value, float min, float max) - { - if (value >= max) - { - return max; - } - - if (value <= min) - { - return min; - } - - return value; - } - - /// - /// Restricts a to be within a specified range. - /// - /// The The value to clamp. - /// The minimum value. If value is less than min, min will be returned. - /// The maximum value. If value is greater than max, max will be returned. - /// - /// The representing the clamped value. - /// - [MethodImpl(InliningOptions.ShortMethod)] - public static double Clamp(this double value, double min, double max) - { - if (value >= max) - { - return max; - } - - if (value <= min) - { - return min; - } - - return value; - } - } -} diff --git a/src/ImageSharp/Common/Helpers/Buffer2DUtils.cs b/src/ImageSharp/Common/Helpers/Buffer2DUtils.cs index f4811d6ca..02a5afff7 100644 --- a/src/ImageSharp/Common/Helpers/Buffer2DUtils.cs +++ b/src/ImageSharp/Common/Helpers/Buffer2DUtils.cs @@ -50,8 +50,8 @@ namespace SixLabors.ImageSharp for (int i = 0; i < kernelLength; i++) { - int offsetY = (row + i - radiusY).Clamp(minRow, maxRow); - int offsetX = sourceOffsetColumnBase.Clamp(minColumn, maxColumn); + int offsetY = Numerics.Clamp(row + i - radiusY, minRow, maxRow); + int offsetX = Numerics.Clamp(sourceOffsetColumnBase, minColumn, maxColumn); Span sourceRowSpan = sourcePixels.GetRowSpan(offsetY); var currentColor = sourceRowSpan[offsetX].ToVector4(); @@ -93,13 +93,13 @@ namespace SixLabors.ImageSharp int radiusX = kernelLength >> 1; int sourceOffsetColumnBase = column + minColumn; - int offsetY = row.Clamp(minRow, maxRow); + int offsetY = Numerics.Clamp(row, minRow, maxRow); ref ComplexVector4 sourceRef = ref MemoryMarshal.GetReference(sourceValues.GetRowSpan(offsetY)); ref Complex64 baseRef = ref MemoryMarshal.GetReference(kernel); for (int x = 0; x < kernelLength; x++) { - int offsetX = (sourceOffsetColumnBase + x - radiusX).Clamp(minColumn, maxColumn); + int offsetX = Numerics.Clamp(sourceOffsetColumnBase + x - radiusX, minColumn, maxColumn); vector.Sum(Unsafe.Add(ref baseRef, x) * Unsafe.Add(ref sourceRef, offsetX)); } diff --git a/src/ImageSharp/Common/Helpers/DenseMatrixUtils.cs b/src/ImageSharp/Common/Helpers/DenseMatrixUtils.cs index 61f90e23e..69c50573f 100644 --- a/src/ImageSharp/Common/Helpers/DenseMatrixUtils.cs +++ b/src/ImageSharp/Common/Helpers/DenseMatrixUtils.cs @@ -133,12 +133,12 @@ namespace SixLabors.ImageSharp for (int y = 0; y < matrixHeight; y++) { - int offsetY = (row + y - radiusY).Clamp(minRow, maxRow); + int offsetY = Numerics.Clamp(row + y - radiusY, minRow, maxRow); Span sourceRowSpan = sourcePixels.GetRowSpan(offsetY); for (int x = 0; x < matrixWidth; x++) { - int offsetX = (sourceOffsetColumnBase + x - radiusX).Clamp(minColumn, maxColumn); + int offsetX = Numerics.Clamp(sourceOffsetColumnBase + x - radiusX, minColumn, maxColumn); var currentColor = sourceRowSpan[offsetX].ToVector4(); Vector4Utilities.Premultiply(ref currentColor); @@ -263,12 +263,12 @@ namespace SixLabors.ImageSharp for (int y = 0; y < matrixHeight; y++) { - int offsetY = (row + y - radiusY).Clamp(minRow, maxRow); + int offsetY = Numerics.Clamp(row + y - radiusY, minRow, maxRow); Span sourceRowSpan = sourcePixels.GetRowSpan(offsetY); for (int x = 0; x < matrixWidth; x++) { - int offsetX = (sourceOffsetColumnBase + x - radiusX).Clamp(minColumn, maxColumn); + int offsetX = Numerics.Clamp(sourceOffsetColumnBase + x - radiusX, minColumn, maxColumn); var currentColor = sourceRowSpan[offsetX].ToVector4(); Vector4Utilities.Premultiply(ref currentColor); vector += matrix[y, x] * currentColor; diff --git a/src/ImageSharp/Common/Helpers/ImageMath.cs b/src/ImageSharp/Common/Helpers/ImageMath.cs index 11fb60209..59f9ad021 100644 --- a/src/ImageSharp/Common/Helpers/ImageMath.cs +++ b/src/ImageSharp/Common/Helpers/ImageMath.cs @@ -248,8 +248,8 @@ namespace SixLabors.ImageSharp topLeft.Y = GetMinY(bitmap); topLeft.X = GetMinX(bitmap); - bottomRight.Y = (GetMaxY(bitmap) + 1).Clamp(0, height); - bottomRight.X = (GetMaxX(bitmap) + 1).Clamp(0, width); + bottomRight.Y = Numerics.Clamp(GetMaxY(bitmap) + 1, 0, height); + bottomRight.X = Numerics.Clamp(GetMaxX(bitmap) + 1, 0, width); return GetBoundingRectangle(topLeft, bottomRight); } diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.cs b/src/ImageSharp/Common/Helpers/SimdUtils.cs index 7691cb9ad..a0cb513ef 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.cs @@ -190,7 +190,7 @@ namespace SixLabors.ImageSharp } [MethodImpl(InliningOptions.ShortMethod)] - private static byte ConvertToByte(float f) => (byte)ComparableExtensions.Clamp((f * 255f) + 0.5f, 0, 255f); + private static byte ConvertToByte(float f) => (byte)Numerics.Clamp((f * 255F) + 0.5F, 0, 255F); [Conditional("DEBUG")] private static void VerifyHasVector8(string operation) diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs index c4ff1c036..36766d05f 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs @@ -212,8 +212,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg ImageMetadata metadata = image.Metadata; // System.Drawing produces identical output for jpegs with a quality parameter of 0 and 1. - int qlty = (this.quality ?? metadata.GetJpegMetadata().Quality).Clamp(1, 100); - this.subsample = this.subsample ?? (qlty >= 91 ? JpegSubsample.Ratio444 : JpegSubsample.Ratio420); + int qlty = Numerics.Clamp(this.quality ?? metadata.GetJpegMetadata().Quality, 1, 100); + this.subsample ??= qlty >= 91 ? JpegSubsample.Ratio444 : JpegSubsample.Ratio420; // Convert from a quality rating to a scaling factor. int scale; diff --git a/src/ImageSharp/Formats/Png/PngEncoderOptionsHelpers.cs b/src/ImageSharp/Formats/Png/PngEncoderOptionsHelpers.cs index 3343923b7..f1f5145ca 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderOptionsHelpers.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderOptionsHelpers.cs @@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.Formats.Png byte bitDepth; if (options.ColorType == PngColorType.Palette) { - byte quantizedBits = (byte)ImageMath.GetBitsNeededForColorDepth(quantizedFrame.Palette.Length).Clamp(1, 8); + byte quantizedBits = (byte)Numerics.Clamp(ImageMath.GetBitsNeededForColorDepth(quantizedFrame.Palette.Length), 1, 8); byte bits = Math.Max((byte)options.BitDepth, quantizedBits); // Png only supports in four pixel depths: 1, 2, 4, and 8 bits when using the PLTE chunk diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.cs index 925a86ac2..8e9cad563 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.cs @@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc /// The new index position public void SetIndex(int index) { - this.currentIndex = index.Clamp(0, this.data.Length); + this.currentIndex = Numerics.Clamp(index, 0, this.data.Length); } /// diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Lut.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Lut.cs index a5eef3d23..40a1792e2 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Lut.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Lut.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. namespace SixLabors.ImageSharp.Metadata.Profiles.Icc @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc { foreach (float item in value.Values) { - this.WriteByte((byte)((item * byte.MaxValue) + 0.5f).Clamp(0, byte.MaxValue)); + this.WriteByte((byte)Numerics.Clamp((item * byte.MaxValue) + 0.5F, 0, byte.MaxValue)); } return value.Values.Length; @@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc { foreach (float item in value.Values) { - this.WriteUInt16((ushort)((item * ushort.MaxValue) + 0.5f).Clamp(0, ushort.MaxValue)); + this.WriteUInt16((ushort)Numerics.Clamp((item * ushort.MaxValue) + 0.5F, 0, ushort.MaxValue)); } return value.Values.Length * 2; @@ -78,7 +78,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc { foreach (float item in inArray) { - count += this.WriteByte((byte)((item * byte.MaxValue) + 0.5f).Clamp(0, byte.MaxValue)); + count += this.WriteByte((byte)Numerics.Clamp((item * byte.MaxValue) + 0.5F, 0, byte.MaxValue)); } } @@ -97,7 +97,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc { foreach (float item in inArray) { - count += this.WriteUInt16((ushort)((item * ushort.MaxValue) + 0.5f).Clamp(0, ushort.MaxValue)); + count += this.WriteUInt16((ushort)Numerics.Clamp((item * ushort.MaxValue) + 0.5F, 0, ushort.MaxValue)); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs index 53dd5f008..305fe47fd 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs @@ -33,9 +33,9 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc /// the number of bytes written public int WriteVersionNumber(in IccVersion value) { - int major = value.Major.Clamp(0, byte.MaxValue); - int minor = value.Minor.Clamp(0, 15); - int bugfix = value.Patch.Clamp(0, 15); + int major = Numerics.Clamp(value.Major, 0, byte.MaxValue); + int minor = Numerics.Clamp(value.Minor, 0, 15); + int bugfix = Numerics.Clamp(value.Patch, 0, 15); int version = (major << 24) | (minor << 20) | (bugfix << 16); return this.WriteInt32(version); diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Primitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Primitives.cs index 5fb8e57d2..c58dd9656 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Primitives.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Primitives.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -112,7 +112,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc const double Max = short.MaxValue + (65535d / 65536d); const double Min = short.MinValue; - value = value.Clamp(Min, Max); + value = Numerics.Clamp(value, Min, Max); value *= 65536d; return this.WriteInt32((int)Math.Round(value, MidpointRounding.AwayFromZero)); @@ -128,7 +128,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc const double Max = ushort.MaxValue + (65535d / 65536d); const double Min = ushort.MinValue; - value = value.Clamp(Min, Max); + value = Numerics.Clamp(value, Min, Max); value *= 65536d; return this.WriteUInt32((uint)Math.Round(value, MidpointRounding.AwayFromZero)); @@ -144,7 +144,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc const double Max = 1 + (32767d / 32768d); const double Min = 0; - value = value.Clamp(Min, Max); + value = Numerics.Clamp(value, Min, Max); value *= 32768d; return this.WriteUInt16((ushort)Math.Round(value, MidpointRounding.AwayFromZero)); @@ -160,7 +160,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc const double Max = byte.MaxValue + (255d / 256d); const double Min = byte.MinValue; - value = value.Clamp(Min, Max); + value = Numerics.Clamp(value, Min, Max); value *= 256d; return this.WriteUInt16((ushort)Math.Round(value, MidpointRounding.AwayFromZero)); diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs index fdbf2a477..25454fa95 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs @@ -240,7 +240,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc count += this.WriteUInt32((uint)value.CurveData.Length); for (int i = 0; i < value.CurveData.Length; i++) { - count += this.WriteUInt16((ushort)((value.CurveData[i] * ushort.MaxValue) + 0.5f).Clamp(0, ushort.MaxValue)); + count += this.WriteUInt16((ushort)Numerics.Clamp((value.CurveData[i] * ushort.MaxValue) + 0.5F, 0, ushort.MaxValue)); } } diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs index 2cb528a03..db61d9383 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs @@ -36,14 +36,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.NormalSrc(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.NormalSrc(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalSrc(background[i], source[i], amount); @@ -55,7 +55,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.NormalSrc(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.NormalSrc(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -74,14 +74,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.MultiplySrc(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.MultiplySrc(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplySrc(background[i], source[i], amount); @@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.MultiplySrc(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.MultiplySrc(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -112,14 +112,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.AddSrc(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.AddSrc(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddSrc(background[i], source[i], amount); @@ -131,7 +131,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.AddSrc(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.AddSrc(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -150,14 +150,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.SubtractSrc(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.SubtractSrc(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractSrc(background[i], source[i], amount); @@ -169,7 +169,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.SubtractSrc(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.SubtractSrc(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -188,14 +188,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.ScreenSrc(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.ScreenSrc(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenSrc(background[i], source[i], amount); @@ -207,7 +207,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.ScreenSrc(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.ScreenSrc(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -226,14 +226,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.DarkenSrc(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.DarkenSrc(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenSrc(background[i], source[i], amount); @@ -245,7 +245,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.DarkenSrc(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.DarkenSrc(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -264,14 +264,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.LightenSrc(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.LightenSrc(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenSrc(background[i], source[i], amount); @@ -283,7 +283,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.LightenSrc(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.LightenSrc(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -302,14 +302,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.OverlaySrc(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.OverlaySrc(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlaySrc(background[i], source[i], amount); @@ -321,7 +321,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.OverlaySrc(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.OverlaySrc(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -340,14 +340,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.HardLightSrc(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.HardLightSrc(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightSrc(background[i], source[i], amount); @@ -359,7 +359,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.HardLightSrc(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.HardLightSrc(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -378,14 +378,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.NormalSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.NormalSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalSrcAtop(background[i], source[i], amount); @@ -397,7 +397,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.NormalSrcAtop(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.NormalSrcAtop(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -416,14 +416,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.MultiplySrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.MultiplySrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplySrcAtop(background[i], source[i], amount); @@ -435,7 +435,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.MultiplySrcAtop(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.MultiplySrcAtop(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -454,14 +454,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.AddSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.AddSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddSrcAtop(background[i], source[i], amount); @@ -473,7 +473,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.AddSrcAtop(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.AddSrcAtop(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -492,14 +492,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.SubtractSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.SubtractSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractSrcAtop(background[i], source[i], amount); @@ -511,7 +511,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.SubtractSrcAtop(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.SubtractSrcAtop(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -530,14 +530,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.ScreenSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.ScreenSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenSrcAtop(background[i], source[i], amount); @@ -549,7 +549,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.ScreenSrcAtop(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.ScreenSrcAtop(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -568,14 +568,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.DarkenSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.DarkenSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenSrcAtop(background[i], source[i], amount); @@ -587,7 +587,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.DarkenSrcAtop(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.DarkenSrcAtop(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -606,14 +606,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.LightenSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.LightenSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenSrcAtop(background[i], source[i], amount); @@ -625,7 +625,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.LightenSrcAtop(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.LightenSrcAtop(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -644,14 +644,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.OverlaySrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.OverlaySrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlaySrcAtop(background[i], source[i], amount); @@ -663,7 +663,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.OverlaySrcAtop(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.OverlaySrcAtop(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -682,14 +682,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.HardLightSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.HardLightSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightSrcAtop(background[i], source[i], amount); @@ -701,7 +701,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.HardLightSrcAtop(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.HardLightSrcAtop(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -720,14 +720,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.NormalSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.NormalSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalSrcOver(background[i], source[i], amount); @@ -739,7 +739,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.NormalSrcOver(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.NormalSrcOver(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -758,14 +758,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.MultiplySrcOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.MultiplySrcOver(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplySrcOver(background[i], source[i], amount); @@ -777,7 +777,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.MultiplySrcOver(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.MultiplySrcOver(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -796,14 +796,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.AddSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.AddSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddSrcOver(background[i], source[i], amount); @@ -815,7 +815,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.AddSrcOver(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.AddSrcOver(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -834,14 +834,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.SubtractSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.SubtractSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractSrcOver(background[i], source[i], amount); @@ -853,7 +853,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.SubtractSrcOver(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.SubtractSrcOver(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -872,14 +872,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.ScreenSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.ScreenSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenSrcOver(background[i], source[i], amount); @@ -891,7 +891,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.ScreenSrcOver(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.ScreenSrcOver(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -910,14 +910,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.DarkenSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.DarkenSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenSrcOver(background[i], source[i], amount); @@ -929,7 +929,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.DarkenSrcOver(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.DarkenSrcOver(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -948,14 +948,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.LightenSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.LightenSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenSrcOver(background[i], source[i], amount); @@ -967,7 +967,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.LightenSrcOver(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.LightenSrcOver(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -986,14 +986,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.OverlaySrcOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.OverlaySrcOver(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlaySrcOver(background[i], source[i], amount); @@ -1005,7 +1005,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.OverlaySrcOver(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.OverlaySrcOver(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1024,14 +1024,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.HardLightSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.HardLightSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightSrcOver(background[i], source[i], amount); @@ -1043,7 +1043,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.HardLightSrcOver(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.HardLightSrcOver(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1062,14 +1062,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.NormalSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.NormalSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalSrcIn(background[i], source[i], amount); @@ -1081,7 +1081,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.NormalSrcIn(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.NormalSrcIn(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1100,14 +1100,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.MultiplySrcIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.MultiplySrcIn(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplySrcIn(background[i], source[i], amount); @@ -1119,7 +1119,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.MultiplySrcIn(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.MultiplySrcIn(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1138,14 +1138,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.AddSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.AddSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddSrcIn(background[i], source[i], amount); @@ -1157,7 +1157,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.AddSrcIn(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.AddSrcIn(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1176,14 +1176,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.SubtractSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.SubtractSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractSrcIn(background[i], source[i], amount); @@ -1195,7 +1195,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.SubtractSrcIn(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.SubtractSrcIn(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1214,14 +1214,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.ScreenSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.ScreenSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenSrcIn(background[i], source[i], amount); @@ -1233,7 +1233,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.ScreenSrcIn(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.ScreenSrcIn(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1252,14 +1252,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.DarkenSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.DarkenSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenSrcIn(background[i], source[i], amount); @@ -1271,7 +1271,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.DarkenSrcIn(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.DarkenSrcIn(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1290,14 +1290,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.LightenSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.LightenSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenSrcIn(background[i], source[i], amount); @@ -1309,7 +1309,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.LightenSrcIn(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.LightenSrcIn(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1328,14 +1328,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.OverlaySrcIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.OverlaySrcIn(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlaySrcIn(background[i], source[i], amount); @@ -1347,7 +1347,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.OverlaySrcIn(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.OverlaySrcIn(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1366,14 +1366,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.HardLightSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.HardLightSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightSrcIn(background[i], source[i], amount); @@ -1385,7 +1385,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.HardLightSrcIn(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.HardLightSrcIn(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1404,14 +1404,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.NormalSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.NormalSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalSrcOut(background[i], source[i], amount); @@ -1423,7 +1423,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.NormalSrcOut(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.NormalSrcOut(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1442,14 +1442,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.MultiplySrcOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.MultiplySrcOut(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplySrcOut(background[i], source[i], amount); @@ -1461,7 +1461,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.MultiplySrcOut(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.MultiplySrcOut(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1480,14 +1480,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.AddSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.AddSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddSrcOut(background[i], source[i], amount); @@ -1499,7 +1499,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.AddSrcOut(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.AddSrcOut(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1518,14 +1518,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.SubtractSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.SubtractSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractSrcOut(background[i], source[i], amount); @@ -1537,7 +1537,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.SubtractSrcOut(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.SubtractSrcOut(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1556,14 +1556,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.ScreenSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.ScreenSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenSrcOut(background[i], source[i], amount); @@ -1575,7 +1575,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.ScreenSrcOut(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.ScreenSrcOut(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1594,14 +1594,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.DarkenSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.DarkenSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenSrcOut(background[i], source[i], amount); @@ -1613,7 +1613,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.DarkenSrcOut(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.DarkenSrcOut(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1632,14 +1632,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.LightenSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.LightenSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenSrcOut(background[i], source[i], amount); @@ -1651,7 +1651,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.LightenSrcOut(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.LightenSrcOut(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1670,14 +1670,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.OverlaySrcOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.OverlaySrcOut(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlaySrcOut(background[i], source[i], amount); @@ -1689,7 +1689,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.OverlaySrcOut(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.OverlaySrcOut(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1708,14 +1708,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.HardLightSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.HardLightSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightSrcOut(background[i], source[i], amount); @@ -1727,7 +1727,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.HardLightSrcOut(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.HardLightSrcOut(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1746,14 +1746,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.NormalDest(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.NormalDest(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalDest(background[i], source[i], amount); @@ -1765,7 +1765,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.NormalDest(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.NormalDest(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1784,14 +1784,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.MultiplyDest(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.MultiplyDest(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyDest(background[i], source[i], amount); @@ -1803,7 +1803,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.MultiplyDest(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.MultiplyDest(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1822,14 +1822,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.AddDest(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.AddDest(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddDest(background[i], source[i], amount); @@ -1841,7 +1841,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.AddDest(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.AddDest(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1860,14 +1860,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.SubtractDest(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.SubtractDest(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractDest(background[i], source[i], amount); @@ -1879,7 +1879,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.SubtractDest(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.SubtractDest(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1898,14 +1898,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.ScreenDest(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.ScreenDest(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenDest(background[i], source[i], amount); @@ -1917,7 +1917,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.ScreenDest(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.ScreenDest(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1936,14 +1936,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.DarkenDest(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.DarkenDest(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenDest(background[i], source[i], amount); @@ -1955,7 +1955,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.DarkenDest(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.DarkenDest(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -1974,14 +1974,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.LightenDest(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.LightenDest(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenDest(background[i], source[i], amount); @@ -1993,7 +1993,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.LightenDest(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.LightenDest(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2012,14 +2012,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.OverlayDest(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.OverlayDest(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayDest(background[i], source[i], amount); @@ -2031,7 +2031,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.OverlayDest(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.OverlayDest(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2050,14 +2050,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.HardLightDest(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.HardLightDest(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightDest(background[i], source[i], amount); @@ -2069,7 +2069,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.HardLightDest(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.HardLightDest(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2088,14 +2088,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.NormalDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.NormalDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalDestAtop(background[i], source[i], amount); @@ -2107,7 +2107,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.NormalDestAtop(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.NormalDestAtop(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2126,14 +2126,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.MultiplyDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.MultiplyDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyDestAtop(background[i], source[i], amount); @@ -2145,7 +2145,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.MultiplyDestAtop(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.MultiplyDestAtop(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2164,14 +2164,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.AddDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.AddDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddDestAtop(background[i], source[i], amount); @@ -2183,7 +2183,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.AddDestAtop(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.AddDestAtop(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2202,14 +2202,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.SubtractDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.SubtractDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractDestAtop(background[i], source[i], amount); @@ -2221,7 +2221,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.SubtractDestAtop(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.SubtractDestAtop(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2240,14 +2240,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.ScreenDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.ScreenDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenDestAtop(background[i], source[i], amount); @@ -2259,7 +2259,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.ScreenDestAtop(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.ScreenDestAtop(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2278,14 +2278,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.DarkenDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.DarkenDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenDestAtop(background[i], source[i], amount); @@ -2297,7 +2297,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.DarkenDestAtop(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.DarkenDestAtop(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2316,14 +2316,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.LightenDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.LightenDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenDestAtop(background[i], source[i], amount); @@ -2335,7 +2335,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.LightenDestAtop(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.LightenDestAtop(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2354,14 +2354,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.OverlayDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.OverlayDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayDestAtop(background[i], source[i], amount); @@ -2373,7 +2373,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.OverlayDestAtop(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.OverlayDestAtop(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2392,14 +2392,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.HardLightDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.HardLightDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightDestAtop(background[i], source[i], amount); @@ -2411,7 +2411,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.HardLightDestAtop(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.HardLightDestAtop(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2430,14 +2430,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.NormalDestOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.NormalDestOver(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalDestOver(background[i], source[i], amount); @@ -2449,7 +2449,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.NormalDestOver(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.NormalDestOver(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2468,14 +2468,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.MultiplyDestOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.MultiplyDestOver(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyDestOver(background[i], source[i], amount); @@ -2487,7 +2487,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.MultiplyDestOver(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.MultiplyDestOver(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2506,14 +2506,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.AddDestOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.AddDestOver(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddDestOver(background[i], source[i], amount); @@ -2525,7 +2525,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.AddDestOver(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.AddDestOver(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2544,14 +2544,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.SubtractDestOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.SubtractDestOver(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractDestOver(background[i], source[i], amount); @@ -2563,7 +2563,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.SubtractDestOver(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.SubtractDestOver(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2582,14 +2582,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.ScreenDestOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.ScreenDestOver(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenDestOver(background[i], source[i], amount); @@ -2601,7 +2601,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.ScreenDestOver(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.ScreenDestOver(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2620,14 +2620,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.DarkenDestOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.DarkenDestOver(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenDestOver(background[i], source[i], amount); @@ -2639,7 +2639,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.DarkenDestOver(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.DarkenDestOver(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2658,14 +2658,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.LightenDestOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.LightenDestOver(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenDestOver(background[i], source[i], amount); @@ -2677,7 +2677,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.LightenDestOver(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.LightenDestOver(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2696,14 +2696,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.OverlayDestOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.OverlayDestOver(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayDestOver(background[i], source[i], amount); @@ -2715,7 +2715,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.OverlayDestOver(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.OverlayDestOver(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2734,14 +2734,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.HardLightDestOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.HardLightDestOver(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightDestOver(background[i], source[i], amount); @@ -2753,7 +2753,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.HardLightDestOver(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.HardLightDestOver(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2772,14 +2772,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.NormalDestIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.NormalDestIn(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalDestIn(background[i], source[i], amount); @@ -2791,7 +2791,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.NormalDestIn(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.NormalDestIn(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2810,14 +2810,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.MultiplyDestIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.MultiplyDestIn(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyDestIn(background[i], source[i], amount); @@ -2829,7 +2829,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.MultiplyDestIn(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.MultiplyDestIn(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2848,14 +2848,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.AddDestIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.AddDestIn(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddDestIn(background[i], source[i], amount); @@ -2867,7 +2867,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.AddDestIn(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.AddDestIn(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2886,14 +2886,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.SubtractDestIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.SubtractDestIn(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractDestIn(background[i], source[i], amount); @@ -2905,7 +2905,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.SubtractDestIn(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.SubtractDestIn(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2924,14 +2924,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.ScreenDestIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.ScreenDestIn(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenDestIn(background[i], source[i], amount); @@ -2943,7 +2943,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.ScreenDestIn(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.ScreenDestIn(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -2962,14 +2962,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.DarkenDestIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.DarkenDestIn(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenDestIn(background[i], source[i], amount); @@ -2981,7 +2981,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.DarkenDestIn(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.DarkenDestIn(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3000,14 +3000,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.LightenDestIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.LightenDestIn(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenDestIn(background[i], source[i], amount); @@ -3019,7 +3019,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.LightenDestIn(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.LightenDestIn(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3038,14 +3038,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.OverlayDestIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.OverlayDestIn(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayDestIn(background[i], source[i], amount); @@ -3057,7 +3057,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.OverlayDestIn(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.OverlayDestIn(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3076,14 +3076,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.HardLightDestIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.HardLightDestIn(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightDestIn(background[i], source[i], amount); @@ -3095,7 +3095,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.HardLightDestIn(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.HardLightDestIn(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3114,14 +3114,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.NormalDestOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.NormalDestOut(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalDestOut(background[i], source[i], amount); @@ -3133,7 +3133,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.NormalDestOut(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.NormalDestOut(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3152,14 +3152,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.MultiplyDestOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.MultiplyDestOut(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyDestOut(background[i], source[i], amount); @@ -3171,7 +3171,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.MultiplyDestOut(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.MultiplyDestOut(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3190,14 +3190,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.AddDestOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.AddDestOut(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddDestOut(background[i], source[i], amount); @@ -3209,7 +3209,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.AddDestOut(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.AddDestOut(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3228,14 +3228,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.SubtractDestOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.SubtractDestOut(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractDestOut(background[i], source[i], amount); @@ -3247,7 +3247,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.SubtractDestOut(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.SubtractDestOut(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3266,14 +3266,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.ScreenDestOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.ScreenDestOut(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenDestOut(background[i], source[i], amount); @@ -3285,7 +3285,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.ScreenDestOut(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.ScreenDestOut(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3304,14 +3304,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.DarkenDestOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.DarkenDestOut(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenDestOut(background[i], source[i], amount); @@ -3323,7 +3323,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.DarkenDestOut(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.DarkenDestOut(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3342,14 +3342,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.LightenDestOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.LightenDestOut(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenDestOut(background[i], source[i], amount); @@ -3361,7 +3361,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.LightenDestOut(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.LightenDestOut(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3380,14 +3380,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.OverlayDestOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.OverlayDestOut(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayDestOut(background[i], source[i], amount); @@ -3399,7 +3399,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.OverlayDestOut(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.OverlayDestOut(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3418,14 +3418,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.HardLightDestOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.HardLightDestOut(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightDestOut(background[i], source[i], amount); @@ -3437,7 +3437,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.HardLightDestOut(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.HardLightDestOut(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3456,14 +3456,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.NormalClear(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.NormalClear(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalClear(background[i], source[i], amount); @@ -3475,7 +3475,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.NormalClear(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.NormalClear(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3494,14 +3494,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.MultiplyClear(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.MultiplyClear(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyClear(background[i], source[i], amount); @@ -3513,7 +3513,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.MultiplyClear(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.MultiplyClear(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3532,14 +3532,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.AddClear(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.AddClear(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddClear(background[i], source[i], amount); @@ -3551,7 +3551,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.AddClear(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.AddClear(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3570,14 +3570,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.SubtractClear(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.SubtractClear(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractClear(background[i], source[i], amount); @@ -3589,7 +3589,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.SubtractClear(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.SubtractClear(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3608,14 +3608,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.ScreenClear(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.ScreenClear(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenClear(background[i], source[i], amount); @@ -3627,7 +3627,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.ScreenClear(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.ScreenClear(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3646,14 +3646,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.DarkenClear(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.DarkenClear(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenClear(background[i], source[i], amount); @@ -3665,7 +3665,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.DarkenClear(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.DarkenClear(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3684,14 +3684,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.LightenClear(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.LightenClear(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenClear(background[i], source[i], amount); @@ -3703,7 +3703,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.LightenClear(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.LightenClear(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3722,14 +3722,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.OverlayClear(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.OverlayClear(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayClear(background[i], source[i], amount); @@ -3741,7 +3741,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.OverlayClear(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.OverlayClear(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3760,14 +3760,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.HardLightClear(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.HardLightClear(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightClear(background[i], source[i], amount); @@ -3779,7 +3779,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.HardLightClear(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.HardLightClear(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3798,14 +3798,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.NormalXor(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.NormalXor(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalXor(background[i], source[i], amount); @@ -3817,7 +3817,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.NormalXor(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.NormalXor(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3836,14 +3836,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.MultiplyXor(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.MultiplyXor(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyXor(background[i], source[i], amount); @@ -3855,7 +3855,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.MultiplyXor(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.MultiplyXor(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3874,14 +3874,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.AddXor(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.AddXor(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddXor(background[i], source[i], amount); @@ -3893,7 +3893,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.AddXor(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.AddXor(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3912,14 +3912,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.SubtractXor(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.SubtractXor(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractXor(background[i], source[i], amount); @@ -3931,7 +3931,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.SubtractXor(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.SubtractXor(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3950,14 +3950,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.ScreenXor(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.ScreenXor(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenXor(background[i], source[i], amount); @@ -3969,7 +3969,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.ScreenXor(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.ScreenXor(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -3988,14 +3988,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.DarkenXor(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.DarkenXor(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenXor(background[i], source[i], amount); @@ -4007,7 +4007,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.DarkenXor(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.DarkenXor(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -4026,14 +4026,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.LightenXor(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.LightenXor(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenXor(background[i], source[i], amount); @@ -4045,7 +4045,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.LightenXor(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.LightenXor(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -4064,14 +4064,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.OverlayXor(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.OverlayXor(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayXor(background[i], source[i], amount); @@ -4083,7 +4083,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.OverlayXor(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.OverlayXor(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } @@ -4102,14 +4102,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.HardLightXor(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.HardLightXor(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightXor(background[i], source[i], amount); @@ -4121,7 +4121,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.HardLightXor(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.HardLightXor(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt index 46990b53c..694931fe7 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt @@ -79,14 +79,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public override TPixel Blend(TPixel background, TPixel source, float amount) { TPixel dest = default; - dest.FromScaledVector4(PorterDuffFunctions.<#=blender_composer#>(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); + dest.FromScaledVector4(PorterDuffFunctions.<#=blender_composer#>(background.ToScaledVector4(), source.ToScaledVector4(), Numerics.Clamp(amount, 0, 1))); return dest; } /// protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { - amount = amount.Clamp(0, 1); + amount = Numerics.Clamp(amount, 0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.<#=blender_composer#>(background[i], source[i], amount); @@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.<#=blender_composer#>(background[i], source[i], amount[i].Clamp(0, 1)); + destination[i] = PorterDuffFunctions.<#=blender_composer#>(background[i], source[i], Numerics.Clamp(amount[i], 0, 1)); } } } diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs index 5fccb1fa6..cd67db32b 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs @@ -203,7 +203,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel NormalSrc(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(NormalSrc(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -222,7 +222,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel NormalSrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(NormalSrcAtop(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -241,7 +241,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel NormalSrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(NormalSrcOver(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -260,7 +260,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel NormalSrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(NormalSrcIn(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -279,7 +279,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel NormalSrcOut(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(NormalSrcOut(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -298,7 +298,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel NormalDest(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(NormalDest(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -317,7 +317,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel NormalDestAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(NormalDestAtop(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -336,7 +336,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel NormalDestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(NormalDestOver(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -355,7 +355,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel NormalDestIn(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(NormalDestIn(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -374,7 +374,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel NormalDestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(NormalDestOut(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -393,7 +393,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel NormalClear(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(NormalClear(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -412,7 +412,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel NormalXor(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(NormalXor(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -608,7 +608,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel MultiplySrc(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(MultiplySrc(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -627,7 +627,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel MultiplySrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(MultiplySrcAtop(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -646,7 +646,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel MultiplySrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(MultiplySrcOver(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -665,7 +665,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel MultiplySrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(MultiplySrcIn(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -684,7 +684,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel MultiplySrcOut(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(MultiplySrcOut(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -703,7 +703,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel MultiplyDest(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(MultiplyDest(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -722,7 +722,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel MultiplyDestAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(MultiplyDestAtop(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -741,7 +741,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel MultiplyDestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(MultiplyDestOver(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -760,7 +760,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel MultiplyDestIn(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(MultiplyDestIn(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -779,7 +779,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel MultiplyDestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(MultiplyDestOut(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -798,7 +798,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel MultiplyClear(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(MultiplyClear(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -817,7 +817,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel MultiplyXor(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(MultiplyXor(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1013,7 +1013,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel AddSrc(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(AddSrc(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1032,7 +1032,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel AddSrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(AddSrcAtop(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1051,7 +1051,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel AddSrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(AddSrcOver(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1070,7 +1070,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel AddSrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(AddSrcIn(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1089,7 +1089,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel AddSrcOut(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(AddSrcOut(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1108,7 +1108,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel AddDest(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(AddDest(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1127,7 +1127,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel AddDestAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(AddDestAtop(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1146,7 +1146,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel AddDestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(AddDestOver(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1165,7 +1165,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel AddDestIn(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(AddDestIn(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1184,7 +1184,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel AddDestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(AddDestOut(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1203,7 +1203,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel AddClear(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(AddClear(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1222,7 +1222,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel AddXor(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(AddXor(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1418,7 +1418,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel SubtractSrc(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(SubtractSrc(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1437,7 +1437,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel SubtractSrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(SubtractSrcAtop(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1456,7 +1456,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel SubtractSrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(SubtractSrcOver(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1475,7 +1475,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel SubtractSrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(SubtractSrcIn(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1494,7 +1494,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel SubtractSrcOut(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(SubtractSrcOut(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1513,7 +1513,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel SubtractDest(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(SubtractDest(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1532,7 +1532,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel SubtractDestAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(SubtractDestAtop(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1551,7 +1551,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel SubtractDestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(SubtractDestOver(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1570,7 +1570,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel SubtractDestIn(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(SubtractDestIn(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1589,7 +1589,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel SubtractDestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(SubtractDestOut(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1608,7 +1608,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel SubtractClear(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(SubtractClear(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1627,7 +1627,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel SubtractXor(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(SubtractXor(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1823,7 +1823,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel ScreenSrc(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(ScreenSrc(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1842,7 +1842,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel ScreenSrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(ScreenSrcAtop(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1861,7 +1861,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel ScreenSrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(ScreenSrcOver(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1880,7 +1880,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel ScreenSrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(ScreenSrcIn(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1899,7 +1899,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel ScreenSrcOut(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(ScreenSrcOut(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1918,7 +1918,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel ScreenDest(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(ScreenDest(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1937,7 +1937,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel ScreenDestAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(ScreenDestAtop(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1956,7 +1956,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel ScreenDestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(ScreenDestOver(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1975,7 +1975,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel ScreenDestIn(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(ScreenDestIn(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -1994,7 +1994,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel ScreenDestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(ScreenDestOut(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2013,7 +2013,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel ScreenClear(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(ScreenClear(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2032,7 +2032,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel ScreenXor(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(ScreenXor(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2228,7 +2228,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel DarkenSrc(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(DarkenSrc(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2247,7 +2247,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel DarkenSrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(DarkenSrcAtop(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2266,7 +2266,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel DarkenSrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(DarkenSrcOver(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2285,7 +2285,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel DarkenSrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(DarkenSrcIn(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2304,7 +2304,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel DarkenSrcOut(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(DarkenSrcOut(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2323,7 +2323,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel DarkenDest(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(DarkenDest(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2342,7 +2342,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel DarkenDestAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(DarkenDestAtop(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2361,7 +2361,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel DarkenDestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(DarkenDestOver(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2380,7 +2380,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel DarkenDestIn(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(DarkenDestIn(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2399,7 +2399,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel DarkenDestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(DarkenDestOut(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2418,7 +2418,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel DarkenClear(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(DarkenClear(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2437,7 +2437,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel DarkenXor(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(DarkenXor(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2633,7 +2633,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel LightenSrc(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(LightenSrc(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2652,7 +2652,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel LightenSrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(LightenSrcAtop(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2671,7 +2671,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel LightenSrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(LightenSrcOver(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2690,7 +2690,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel LightenSrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(LightenSrcIn(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2709,7 +2709,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel LightenSrcOut(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(LightenSrcOut(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2728,7 +2728,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel LightenDest(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(LightenDest(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2747,7 +2747,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel LightenDestAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(LightenDestAtop(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2766,7 +2766,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel LightenDestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(LightenDestOver(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2785,7 +2785,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel LightenDestIn(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(LightenDestIn(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2804,7 +2804,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel LightenDestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(LightenDestOut(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2823,7 +2823,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel LightenClear(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(LightenClear(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -2842,7 +2842,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel LightenXor(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(LightenXor(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3038,7 +3038,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel OverlaySrc(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(OverlaySrc(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3057,7 +3057,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel OverlaySrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(OverlaySrcAtop(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3076,7 +3076,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel OverlaySrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(OverlaySrcOver(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3095,7 +3095,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel OverlaySrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(OverlaySrcIn(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3114,7 +3114,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel OverlaySrcOut(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(OverlaySrcOut(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3133,7 +3133,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel OverlayDest(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(OverlayDest(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3152,7 +3152,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel OverlayDestAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(OverlayDestAtop(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3171,7 +3171,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel OverlayDestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(OverlayDestOver(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3190,7 +3190,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel OverlayDestIn(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(OverlayDestIn(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3209,7 +3209,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel OverlayDestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(OverlayDestOut(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3228,7 +3228,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel OverlayClear(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(OverlayClear(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3247,7 +3247,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel OverlayXor(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(OverlayXor(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3443,7 +3443,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel HardLightSrc(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(HardLightSrc(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3462,7 +3462,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel HardLightSrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(HardLightSrcAtop(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3481,7 +3481,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel HardLightSrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(HardLightSrcOver(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3500,7 +3500,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel HardLightSrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(HardLightSrcIn(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3519,7 +3519,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel HardLightSrcOut(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(HardLightSrcOut(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3538,7 +3538,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel HardLightDest(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(HardLightDest(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3557,7 +3557,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel HardLightDestAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(HardLightDestAtop(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3576,7 +3576,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel HardLightDestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(HardLightDestOver(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3595,7 +3595,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel HardLightDestIn(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(HardLightDestIn(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3614,7 +3614,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel HardLightDestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(HardLightDestOut(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3633,7 +3633,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel HardLightClear(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(HardLightClear(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; @@ -3652,7 +3652,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel HardLightXor(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(HardLightXor(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt index 31b502908..3ce185e7d 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt @@ -219,7 +219,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static TPixel <#=blender#><#=composer#>(TPixel backdrop, TPixel source, float opacity) where TPixel : unmanaged, IPixel { - opacity = opacity.Clamp(0, 1); + opacity = Numerics.Clamp(opacity, 0, 1); TPixel dest = default; dest.FromScaledVector4(<#=blender#><#=composer#>(backdrop.ToScaledVector4(), source.ToScaledVector4(), opacity)); return dest; diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/A8.cs b/src/ImageSharp/PixelFormats/PixelImplementations/A8.cs index c293d181a..fa08bbe62 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/A8.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/A8.cs @@ -162,6 +162,6 @@ namespace SixLabors.ImageSharp.PixelFormats /// The float containing the value to pack. /// The containing the packed values. [MethodImpl(InliningOptions.ShortMethod)] - private static byte Pack(float alpha) => (byte)Math.Round(alpha.Clamp(0, 1F) * 255F); + private static byte Pack(float alpha) => (byte)Math.Round(Numerics.Clamp(alpha, 0, 1F) * 255F); } } diff --git a/src/ImageSharp/Primitives/Number.cs b/src/ImageSharp/Primitives/Number.cs index f6748d856..e33d2344a 100644 --- a/src/ImageSharp/Primitives/Number.cs +++ b/src/ImageSharp/Primitives/Number.cs @@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp { return number.isSigned ? number.signedValue - : (int)number.unsignedValue.Clamp(0, int.MaxValue); + : (int)Numerics.Clamp(number.unsignedValue, 0, int.MaxValue); } /// @@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp public static explicit operator uint(Number number) { return number.isSigned - ? (uint)number.signedValue.Clamp(0, int.MaxValue) + ? (uint)Numerics.Clamp(number.signedValue, 0, int.MaxValue) : number.unsignedValue; } @@ -91,8 +91,8 @@ namespace SixLabors.ImageSharp public static explicit operator ushort(Number number) { return number.isSigned - ? (ushort)number.signedValue.Clamp(ushort.MinValue, ushort.MaxValue) - : (ushort)number.unsignedValue.Clamp(ushort.MinValue, ushort.MaxValue); + ? (ushort)Numerics.Clamp(number.signedValue, ushort.MinValue, ushort.MaxValue) + : (ushort)Numerics.Clamp(number.unsignedValue, ushort.MinValue, ushort.MaxValue); } /// diff --git a/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs b/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs index 80c777cd7..0f3c20f5e 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs @@ -165,10 +165,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering int spread = 256 / bitDepth; float factor = spread * this.thresholdMatrix[y % this.modulusY, x % this.modulusX] * scale; - attempt.R = (byte)(rgba.R + factor).Clamp(byte.MinValue, byte.MaxValue); - attempt.G = (byte)(rgba.G + factor).Clamp(byte.MinValue, byte.MaxValue); - attempt.B = (byte)(rgba.B + factor).Clamp(byte.MinValue, byte.MaxValue); - attempt.A = (byte)(rgba.A + factor).Clamp(byte.MinValue, byte.MaxValue); + attempt.R = (byte)Numerics.Clamp(rgba.R + factor, byte.MinValue, byte.MaxValue); + attempt.G = (byte)Numerics.Clamp(rgba.G + factor, byte.MinValue, byte.MaxValue); + attempt.B = (byte)Numerics.Clamp(rgba.B + factor, byte.MinValue, byte.MaxValue); + attempt.A = (byte)Numerics.Clamp(rgba.A + factor, byte.MinValue, byte.MaxValue); TPixel result = default; result.FromRgba32(attempt); diff --git a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor.cs b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor.cs index bb6614a7e..1b321a99f 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor.cs @@ -52,7 +52,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering Guard.MustBeGreaterThan(palette.Length, 0, nameof(palette)); Guard.NotNull(dither, nameof(dither)); this.Dither = dither; - this.DitherScale = ditherScale.Clamp(QuantizerConstants.MinDitherScale, QuantizerConstants.MaxDitherScale); + this.DitherScale = Numerics.Clamp(ditherScale, QuantizerConstants.MinDitherScale, QuantizerConstants.MaxDitherScale); this.Palette = palette; } diff --git a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs index 21ec8a9c7..42216417e 100644 --- a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs @@ -137,8 +137,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects { int fyr = fy - this.radius; int offsetY = y + fyr; - - offsetY = offsetY.Clamp(0, maxY); + offsetY = Numerics.Clamp(offsetY, 0, maxY); Span sourceOffsetRow = this.source.GetPixelRowSpan(offsetY); @@ -146,7 +145,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects { int fxr = fx - this.radius; int offsetX = x + fxr; - offsetX = offsetX.Clamp(0, maxX); + offsetX = Numerics.Clamp(offsetX, 0, maxX); var vector = sourceOffsetRow[offsetX].ToVector4(); diff --git a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs index c028903f4..78cf7f3c6 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs @@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays for (int i = 0; i < this.bounds.Width; i++) { float distance = Vector2.Distance(this.center, new Vector2(i + this.bounds.X, y)); - span[i] = (this.blendPercent * (1 - (.95F * (distance / this.maxDistance)))).Clamp(0, 1); + span[i] = Numerics.Clamp(this.blendPercent * (1 - (.95F * (distance / this.maxDistance))), 0, 1F); } Span destination = this.source.GetPixelRowSpan(y).Slice(this.bounds.X, this.bounds.Width); diff --git a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs index d09e3b22a..c853377ad 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs @@ -110,7 +110,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays for (int i = 0; i < this.bounds.Width; i++) { float distance = Vector2.Distance(this.center, new Vector2(i + this.bounds.X, y)); - span[i] = (this.blendPercent * (.9F * (distance / this.maxDistance))).Clamp(0, 1); + span[i] = Numerics.Clamp(this.blendPercent * (.9F * (distance / this.maxDistance)), 0, 1F); } Span destination = this.source.GetPixelRowSpan(y).Slice(this.bounds.X, this.bounds.Width); diff --git a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs index 50eeef8ca..1e1d1c953 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs @@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization this.Options = options; this.maxColors = this.Options.MaxColors; - this.octree = new Octree(ImageMath.GetBitsNeededForColorDepth(this.maxColors).Clamp(1, 8)); + this.octree = new Octree(Numerics.Clamp(ImageMath.GetBitsNeededForColorDepth(this.maxColors), 1, 8)); this.paletteOwner = configuration.MemoryAllocator.Allocate(this.maxColors, AllocationOptions.Clean); this.palette = default; this.pixelMap = default; diff --git a/src/ImageSharp/Processing/Processors/Quantization/QuantizerOptions.cs b/src/ImageSharp/Processing/Processors/Quantization/QuantizerOptions.cs index d30481043..b983904d2 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/QuantizerOptions.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/QuantizerOptions.cs @@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization public float DitherScale { get { return this.ditherScale; } - set { this.ditherScale = value.Clamp(QuantizerConstants.MinDitherScale, QuantizerConstants.MaxDitherScale); } + set { this.ditherScale = Numerics.Clamp(value, QuantizerConstants.MinDitherScale, QuantizerConstants.MaxDitherScale); } } /// @@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization public int MaxColors { get { return this.maxColors; } - set { this.maxColors = value.Clamp(QuantizerConstants.MinColors, QuantizerConstants.MaxColors); } + set { this.maxColors = Numerics.Clamp(value, QuantizerConstants.MinColors, QuantizerConstants.MaxColors); } } } } diff --git a/tests/ImageSharp.Benchmarks/Color/YcbCrToRgb.cs b/tests/ImageSharp.Benchmarks/Color/YcbCrToRgb.cs index c962886d1..07707029a 100644 --- a/tests/ImageSharp.Benchmarks/Color/YcbCrToRgb.cs +++ b/tests/ImageSharp.Benchmarks/Color/YcbCrToRgb.cs @@ -1,12 +1,11 @@ // Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. +using System.Numerics; +using BenchmarkDotNet.Attributes; + namespace SixLabors.ImageSharp.Benchmarks { - using System.Numerics; - - using BenchmarkDotNet.Attributes; - public class YcbCrToRgb { [Benchmark(Baseline = true, Description = "Floating Point Conversion")] @@ -19,9 +18,9 @@ namespace SixLabors.ImageSharp.Benchmarks int ccb = cb - 128; int ccr = cr - 128; - byte r = (byte)(y + (1.402F * ccr)).Clamp(0, 255); - byte g = (byte)(y - (0.34414F * ccb) - (0.71414F * ccr)).Clamp(0, 255); - byte b = (byte)(y + (1.772F * ccb)).Clamp(0, 255); + byte r = (byte)Numerics.Clamp(y + (1.402F * ccr), 0, 255); + byte g = (byte)Numerics.Clamp(y - (0.34414F * ccb) - (0.71414F * ccr), 0, 255); + byte b = (byte)Numerics.Clamp(y + (1.772F * ccb), 0, 255); return new Vector3(r, g, b); } @@ -42,9 +41,9 @@ namespace SixLabors.ImageSharp.Benchmarks int g1 = 731 * ccr; // (0.71414F * 1024) + .5F int b0 = 1815 * ccb; // (1.772F * 1024) + .5F - byte r = (byte)(y + (r0 >> 10)).Clamp(0, 255); - byte g = (byte)(y - (g0 >> 10) - (g1 >> 10)).Clamp(0, 255); - byte b = (byte)(y + (b0 >> 10)).Clamp(0, 255); + byte r = (byte)Numerics.Clamp(y + (r0 >> 10), 0, 255); + byte g = (byte)Numerics.Clamp(y - (g0 >> 10) - (g1 >> 10), 0, 255); + byte b = (byte)Numerics.Clamp(y + (b0 >> 10), 0, 255); return new Vector3(r, g, b); } diff --git a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs index a5b49721d..f69dca26e 100644 --- a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs +++ b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs @@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General.BasicMath for (int i = 0; i < A.Length; i++) { ref int x = ref A[i]; - x = x.Clamp(64, 128); + x = Numerics.Clamp(x, 64, 128); } }