mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-26 21:18:24 +01:00
SOURCE DUMP v1
This commit is contained in:
parent
bd62d51ec9
commit
fb20299e9d
9 changed files with 768360 additions and 0 deletions
|
|
@ -0,0 +1,28 @@
|
|||
// <auto-generated /> - edit Vector.copy.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct ushort2
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly void CopyTo(Span<ushort> destination)
|
||||
{
|
||||
if (destination.Length < ComponentCount)
|
||||
throw new ArgumentException("Length must be at least 2.", nameof(destination));
|
||||
|
||||
Unsafe.WriteUnaligned(ref Unsafe.As<ushort, byte>(ref MemoryMarshal.GetReference(destination)), this);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly bool TryCopyTo(Span<ushort> destination)
|
||||
{
|
||||
if (destination.Length < ComponentCount)
|
||||
return false;
|
||||
|
||||
Unsafe.WriteUnaligned(ref Unsafe.As<ushort, byte>(ref MemoryMarshal.GetReference(destination)), this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
// <auto-generated /> - edit Vector.equality.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct ushort2
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public readonly override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(X, Y);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly bool Equals(ushort2 other)
|
||||
{
|
||||
return X.Equals(other.X) && Y.Equals(other.Y);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly override bool Equals([NotNullWhen(true)] object? obj)
|
||||
{
|
||||
return obj is ushort2 other && Equals(other);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator ==(ushort2 a, ushort2 b)
|
||||
{
|
||||
return a.X == b.X && a.Y == b.Y;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator !=(ushort2 a, ushort2 b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
// <auto-generated /> - edit Vector.format.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct ushort2 : ISpanFormattable, IUtf8SpanFormattable, ISpanParsable<ushort2>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public readonly override string ToString()
|
||||
{
|
||||
return ToString("G", CultureInfo.CurrentCulture);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.ToString(string?)" />
|
||||
public readonly string ToString(string? format)
|
||||
{
|
||||
return ToString(format, CultureInfo.CurrentCulture);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public readonly string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
var separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
|
||||
return $"<{X.ToString(format, formatProvider)}{separator} {Y.ToString(format, formatProvider)}>";
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
||||
{
|
||||
return StringHelpers.TryFormat<ushort2, ushort>(this, destination, out charsWritten, format, provider);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public readonly bool TryFormat(Span<byte> destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
||||
{
|
||||
return StringHelpers.TryFormat<ushort2, ushort>(this, destination, out bytesWritten, format, provider);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
|
||||
public static ushort2 Parse(string s, IFormatProvider? provider)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(s);
|
||||
return Parse(s.AsSpan(), NumberStyles.Integer, provider);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
|
||||
public static ushort2 Parse(ReadOnlySpan<char> s, IFormatProvider? provider = null)
|
||||
{
|
||||
return Parse(s, NumberStyles.Integer, provider);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
|
||||
public static ushort2 Parse(string s, NumberStyles style, IFormatProvider? provider)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(s);
|
||||
return Parse(s.AsSpan(), style, provider);
|
||||
}
|
||||
|
||||
/// <summary>Parses from the <see cref="ToString()" /> format, <c><1, 2, 3></c>.</summary>
|
||||
/// <exception cref="FormatException">The input is not in a valid format, or a component fails to parse.</exception>
|
||||
public static ushort2 Parse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider)
|
||||
{
|
||||
if (!TryParse(s, style, provider, out var result))
|
||||
throw new FormatException($"'{s}' is not in a valid ushort2 format.");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out ushort2)" />
|
||||
public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out ushort2 result)
|
||||
{
|
||||
return TryParse(s.AsSpan(), NumberStyles.Integer, provider, out result);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out ushort2)" />
|
||||
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out ushort2 result)
|
||||
{
|
||||
return TryParse(s, NumberStyles.Integer, provider, out result);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out ushort2)" />
|
||||
public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out ushort2 result)
|
||||
{
|
||||
return TryParse(s.AsSpan(), style, provider, out result);
|
||||
}
|
||||
|
||||
/// <summary>Parses from the <see cref="ToString()" /> format, <c><1, 2, 3></c>.</summary>
|
||||
/// <returns>true if the input parsed as a ushort2.</returns>
|
||||
public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out ushort2 result)
|
||||
{
|
||||
return StringHelpers.TryParse<ushort2, ushort>(s, style, provider, out result);
|
||||
}
|
||||
}
|
||||
106
brutal.numerics/Brutal.Numerics/Vector/ushort2/ushort2.gen.cs
Normal file
106
brutal.numerics/Brutal.Numerics/Vector/ushort2/ushort2.gen.cs
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
// <auto-generated /> - edit Vector.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
/// <summary>
|
||||
/// Implements a 2D vector with ushort components.
|
||||
/// </summary>
|
||||
[DebuggerTypeProxy(typeof(VectorDebugView2<ushort2, ushort, float>))]
|
||||
public partial struct ushort2 : IVector2<ushort2, ushort>
|
||||
, IIntegerVector<ushort2, ushort, int, float>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public static int ComponentSize => sizeof(ushort);
|
||||
|
||||
/// <summary>Gets the number of components.</summary>
|
||||
public static int ComponentCount => 2;
|
||||
|
||||
/// <inheritdoc cref="Vector2.X" />
|
||||
[XmlAttribute]
|
||||
public ushort X;
|
||||
|
||||
/// <inheritdoc cref="Vector2.Y" />
|
||||
[XmlAttribute]
|
||||
public ushort Y;
|
||||
|
||||
ushort IVector2<ushort2, ushort>.X { readonly get => X; set => X = value; }
|
||||
|
||||
ushort IVector2<ushort2, ushort>.Y { readonly get => Y; set => Y = value; }
|
||||
|
||||
/// <inheritdoc cref="Vector2(float, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ushort2(ushort x, ushort y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2(float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ushort2(ushort xy)
|
||||
: this(xy, xy) { }
|
||||
|
||||
/// <summary>Creates a vector from the leading 2 elements of a span.</summary>
|
||||
/// <param name="span">The elements to read; must contain at least 2, and any beyond that are ignored.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="span" /> holds fewer than 2 elements.</exception>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ushort2(ReadOnlySpan<ushort> span)
|
||||
{
|
||||
if (span.Length < 2)
|
||||
throw new ArgumentOutOfRangeException(nameof(span), "Length must be at least 2.");
|
||||
|
||||
this = Unsafe.ReadUnaligned<ushort2>(ref Unsafe.As<ushort, byte>(ref MemoryMarshal.GetReference(span)));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ushort2(ReadOnlySpan{ushort})" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static ushort2 IComponentTuple<ushort2, ushort>.Create(ReadOnlySpan<ushort> span) => new(span);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static ushort2 UnitX => new(1, 0);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static ushort2 UnitY => new(0, 1);
|
||||
|
||||
/// <inheritdoc />
|
||||
public ushort this[int index]
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get
|
||||
{
|
||||
if ((uint)index >= ComponentCount)
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
|
||||
return Unsafe.Add(ref Unsafe.AsRef(in X), index);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set
|
||||
{
|
||||
if ((uint)index >= ComponentCount)
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
|
||||
Unsafe.Add(ref X, index) = value;
|
||||
}
|
||||
}
|
||||
|
||||
public readonly void Deconstruct(out ushort x, out ushort y)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Span<ushort> AsSpan()
|
||||
{
|
||||
return MemoryMarshal.CreateSpan(ref Unsafe.As<ushort2, ushort>(ref this), 2);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly ReadOnlySpan<ushort> AsReadOnlySpan()
|
||||
{
|
||||
return MemoryMarshal.CreateReadOnlySpan(in Unsafe.As<ushort2, ushort>(ref Unsafe.AsRef(in this)), 2);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
// <auto-generated /> - edit Vector.math-metric.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct ushort2
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly float Length()
|
||||
{
|
||||
return (float)double.Sqrt((double)X * X + (double)Y * Y);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly int LengthSquared()
|
||||
{
|
||||
return Dot(this, this);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Distance" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float Distance(ushort2 a, ushort2 b)
|
||||
{
|
||||
return (float)double.Sqrt(((double)a.X - b.X) * ((double)a.X - b.X) + ((double)a.Y - b.Y) * ((double)a.Y - b.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.DistanceSquared" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int DistanceSquared(ushort2 a, ushort2 b)
|
||||
{
|
||||
return (a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Dot" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int Dot(ushort2 a, ushort2 b)
|
||||
{
|
||||
return a.X * b.X + a.Y * b.Y;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
// <auto-generated /> - edit Vector.numerics-binary.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
// IBinaryNumber
|
||||
public partial struct ushort2 : IBinaryNumber<ushort2>
|
||||
{
|
||||
/// <summary>Determines if every component of a value is a power of two.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool IBinaryNumber<ushort2>.IsPow2(ushort2 value)
|
||||
{
|
||||
return ushort.IsPow2(value.X) && ushort.IsPow2(value.Y);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IBinaryNumber{TSelf}.Log2" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 Log2(ushort2 value)
|
||||
{
|
||||
return new ushort2(ushort.Log2(value.X), ushort.Log2(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 operator &(ushort2 a, ushort2 b)
|
||||
{
|
||||
return new((ushort)(a.X & b.X), (ushort)(a.Y & b.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 operator |(ushort2 a, ushort2 b)
|
||||
{
|
||||
return new((ushort)(a.X | b.X), (ushort)(a.Y | b.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 operator ^(ushort2 a, ushort2 b)
|
||||
{
|
||||
return new((ushort)(a.X ^ b.X), (ushort)(a.Y ^ b.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 operator ~(ushort2 value)
|
||||
{
|
||||
return new((ushort)(~value.X), (ushort)(~value.Y));
|
||||
}
|
||||
}
|
||||
|
||||
// the componentwise predicate mask (no interface to mirror) - the per-lane truth IsPow2 collapses
|
||||
public partial struct ushort2
|
||||
{
|
||||
/// <summary>Determines which components of a value are powers of two.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 IsPow2(ushort2 value)
|
||||
{
|
||||
return new bool2(ushort.IsPow2(value.X), ushort.IsPow2(value.Y));
|
||||
}
|
||||
}
|
||||
|
||||
// the good bits from IBinaryInteger - declared on IIntegerVector
|
||||
public partial struct ushort2
|
||||
{
|
||||
/// <inheritdoc cref="IBinaryInteger{TSelf}.PopCount" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 PopCount(ushort2 value)
|
||||
{
|
||||
return new ushort2(ushort.PopCount(value.X), ushort.PopCount(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IBinaryInteger{TSelf}.LeadingZeroCount" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 LeadingZeroCount(ushort2 value)
|
||||
{
|
||||
return new ushort2(ushort.LeadingZeroCount(value.X), ushort.LeadingZeroCount(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IBinaryInteger{TSelf}.TrailingZeroCount" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 TrailingZeroCount(ushort2 value)
|
||||
{
|
||||
return new ushort2(ushort.TrailingZeroCount(value.X), ushort.TrailingZeroCount(value.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IBinaryInteger{TSelf}.RotateLeft" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 RotateLeft(ushort2 value, int rotateAmount)
|
||||
{
|
||||
return new ushort2(ushort.RotateLeft(value.X, rotateAmount), ushort.RotateLeft(value.Y, rotateAmount));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IBinaryInteger{TSelf}.RotateRight" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 RotateRight(ushort2 value, int rotateAmount)
|
||||
{
|
||||
return new ushort2(ushort.RotateRight(value.X, rotateAmount), ushort.RotateRight(value.Y, rotateAmount));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,389 @@
|
|||
// <auto-generated /> - edit Vector.numerics.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
// INumberBase
|
||||
public partial struct ushort2 : INumberBase<ushort2>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public static ushort2 Zero => new(0);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static ushort2 One => new(1);
|
||||
|
||||
static ushort2 IAdditiveIdentity<ushort2, ushort2>.AdditiveIdentity => Zero;
|
||||
|
||||
static ushort2 IMultiplicativeIdentity<ushort2, ushort2>.MultiplicativeIdentity => One;
|
||||
|
||||
static int INumberBase<ushort2>.Radix => 2; // every component type is binary
|
||||
|
||||
static ushort2 INumberBase<ushort2>.Abs(ushort2 value) => value;
|
||||
|
||||
static bool INumberBase<ushort2>.IsCanonical(ushort2 value) => true;
|
||||
|
||||
static bool INumberBase<ushort2>.IsComplexNumber(ushort2 value) => false;
|
||||
|
||||
static bool INumberBase<ushort2>.IsImaginaryNumber(ushort2 value) => false;
|
||||
|
||||
/// <summary>Determines if every component of a value is zero.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<ushort2>.IsZero(ushort2 value)
|
||||
{
|
||||
return value == Zero;
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is an even integral value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<ushort2>.IsEvenInteger(ushort2 value)
|
||||
{
|
||||
return (value.X & 1) == 0 && (value.Y & 1) == 0;
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is an odd integral value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<ushort2>.IsOddInteger(ushort2 value)
|
||||
{
|
||||
return (value.X & 1) == 1 && (value.Y & 1) == 1;
|
||||
}
|
||||
|
||||
static bool INumberBase<ushort2>.IsNegative(ushort2 value) => false;
|
||||
|
||||
static bool INumberBase<ushort2>.IsPositive(ushort2 value) => true;
|
||||
|
||||
static bool INumberBase<ushort2>.IsFinite(ushort2 value) => true;
|
||||
|
||||
static bool INumberBase<ushort2>.IsInfinity(ushort2 value) => false;
|
||||
|
||||
static bool INumberBase<ushort2>.IsNegativeInfinity(ushort2 value) => false;
|
||||
|
||||
static bool INumberBase<ushort2>.IsPositiveInfinity(ushort2 value) => false;
|
||||
|
||||
static bool INumberBase<ushort2>.IsInteger(ushort2 value) => true;
|
||||
|
||||
static bool INumberBase<ushort2>.IsRealNumber(ushort2 value) => true;
|
||||
|
||||
static bool INumberBase<ushort2>.IsNaN(ushort2 value) => false;
|
||||
|
||||
static bool INumberBase<ushort2>.IsNormal(ushort2 value) => value.X != 0 && value.Y != 0;
|
||||
|
||||
static bool INumberBase<ushort2>.IsSubnormal(ushort2 value) => false;
|
||||
|
||||
/// <summary>Computes, componentwise, the value whose magnitude is greater.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 MaxMagnitude(ushort2 a, ushort2 b)
|
||||
{
|
||||
return Max(a, b);
|
||||
}
|
||||
|
||||
/// <summary>Computes, componentwise, the value whose magnitude is greater.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 MaxMagnitudeNumber(ushort2 a, ushort2 b)
|
||||
{
|
||||
return Max(a, b);
|
||||
}
|
||||
|
||||
/// <summary>Computes, componentwise, the value whose magnitude is smaller.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 MinMagnitude(ushort2 a, ushort2 b)
|
||||
{
|
||||
return Min(a, b);
|
||||
}
|
||||
|
||||
/// <summary>Computes, componentwise, the value whose magnitude is smaller.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 MinMagnitudeNumber(ushort2 a, ushort2 b)
|
||||
{
|
||||
return Min(a, b);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Add" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 Add(ushort2 a, ushort2 b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Divide(Vector2, Vector2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 Divide(ushort2 a, ushort2 b)
|
||||
{
|
||||
return a / b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Multiply(Vector2, Vector2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 Multiply(ushort2 a, ushort2 b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Negate" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 Negate(ushort2 value)
|
||||
{
|
||||
return -value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Subtract" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 Subtract(ushort2 a, ushort2 b)
|
||||
{
|
||||
return a - b;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 operator +(ushort2 a, ushort2 b)
|
||||
{
|
||||
return new((ushort)(a.X + b.X), (ushort)(a.Y + b.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 operator -(ushort2 a, ushort2 b)
|
||||
{
|
||||
return new((ushort)(a.X - b.X), (ushort)(a.Y - b.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 operator *(ushort2 a, ushort2 b)
|
||||
{
|
||||
return new((ushort)(a.X * b.X), (ushort)(a.Y * b.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 operator /(ushort2 a, ushort2 b)
|
||||
{
|
||||
return new((ushort)(a.X / b.X), (ushort)(a.Y / b.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 operator -(ushort2 a)
|
||||
{
|
||||
return new((ushort)(0 - a.X), (ushort)(0 - a.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 operator +(ushort2 a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
// ++/-- are well-defined (+/- One) but a footgun on a concrete vector: generic-plane only.
|
||||
|
||||
static ushort2 IIncrementOperators<ushort2>.operator ++(ushort2 value) => value + One;
|
||||
|
||||
static ushort2 IDecrementOperators<ushort2>.operator --(ushort2 value) => value - One;
|
||||
|
||||
|
||||
static bool INumberBase<ushort2>.TryConvertFromChecked<TOther>(TOther value, out ushort2 result)
|
||||
{
|
||||
return NumberConversion.TryConvertFrom<ushort2, ushort, TOther, NumberConversion.Checked>(value, out result);
|
||||
}
|
||||
|
||||
static bool INumberBase<ushort2>.TryConvertToChecked<TOther>(ushort2 value, [MaybeNullWhen(false)] out TOther result)
|
||||
{
|
||||
result = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool INumberBase<ushort2>.TryConvertFromSaturating<TOther>(TOther value, out ushort2 result)
|
||||
{
|
||||
return NumberConversion.TryConvertFrom<ushort2, ushort, TOther, NumberConversion.Saturating>(value, out result);
|
||||
}
|
||||
|
||||
static bool INumberBase<ushort2>.TryConvertToSaturating<TOther>(ushort2 value, [MaybeNullWhen(false)] out TOther result)
|
||||
{
|
||||
result = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool INumberBase<ushort2>.TryConvertFromTruncating<TOther>(TOther value, out ushort2 result)
|
||||
{
|
||||
return NumberConversion.TryConvertFrom<ushort2, ushort, TOther, NumberConversion.Truncating>(value, out result);
|
||||
}
|
||||
|
||||
static bool INumberBase<ushort2>.TryConvertToTruncating<TOther>(ushort2 value, [MaybeNullWhen(false)] out TOther result)
|
||||
{
|
||||
result = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// IMultiplyOperators<TSelf, TComponent, TSelf>, IDivisionOperators<TSelf, TComponent, TSelf>
|
||||
public partial struct ushort2
|
||||
: IMultiplyOperators<ushort2, ushort, ushort2>
|
||||
, IDivisionOperators<ushort2, ushort, ushort2>
|
||||
{
|
||||
/// <inheritdoc cref="Vector2.Divide(Vector2, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 Divide(ushort2 a, ushort b)
|
||||
{
|
||||
return a / b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Multiply(Vector2, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 Multiply(ushort2 a, ushort b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Multiply(float, Vector2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 Multiply(ushort a, ushort2 b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 operator *(ushort2 a, ushort b)
|
||||
{
|
||||
return new((ushort)(a.X * b), (ushort)(a.Y * b));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 operator /(ushort2 a, ushort b)
|
||||
{
|
||||
return new((ushort)(a.X / b), (ushort)(a.Y / b));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 operator *(ushort a, ushort2 b)
|
||||
{
|
||||
return new((ushort)(a * b.X), (ushort)(a * b.Y));
|
||||
}
|
||||
}
|
||||
|
||||
// INumber
|
||||
public partial struct ushort2 : INumber<ushort2>
|
||||
{
|
||||
/// <inheritdoc cref="Vector2.Clamp" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 Clamp(ushort2 value, ushort2 min, ushort2 max)
|
||||
{
|
||||
// HLSL contract when min > max: max wins (clamp is Max-then-Min); pinned in
|
||||
// Clamp_InvertedBounds_MatchesBcl. NOT scalar T.Clamp, which throws on inversion.
|
||||
return Min(Max(value, min), max);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Max" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 Max(ushort2 a, ushort2 b)
|
||||
{
|
||||
return new(ushort.Max(a.X, b.X), ushort.Max(a.Y, b.Y));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector2.Min" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 Min(ushort2 a, ushort2 b)
|
||||
{
|
||||
return new(ushort.Min(a.X, b.X), ushort.Min(a.Y, b.Y));
|
||||
}
|
||||
|
||||
static ushort2 INumber<ushort2>.MaxNumber(ushort2 a, ushort2 b) => Max(a, b);
|
||||
|
||||
static ushort2 INumber<ushort2>.MinNumber(ushort2 a, ushort2 b) => Min(a, b);
|
||||
|
||||
static ushort2 INumber<ushort2>.CopySign(ushort2 value, ushort2 sign) => value;
|
||||
|
||||
// the Native variants permit either NaN/signed-zero behavior - forwarding is always legal
|
||||
static ushort2 INumber<ushort2>.ClampNative(ushort2 value, ushort2 min, ushort2 max) => Clamp(value, min, max);
|
||||
|
||||
static ushort2 INumber<ushort2>.MaxNative(ushort2 a, ushort2 b) => Max(a, b);
|
||||
|
||||
static ushort2 INumber<ushort2>.MinNative(ushort2 a, ushort2 b) => Min(a, b);
|
||||
|
||||
// Sign's int return cannot hold a per-lane answer, and a collapsed one would lie for mixed signs
|
||||
static int INumber<ushort2>.Sign(ushort2 value) =>
|
||||
throw new NotSupportedException($"{nameof(ushort2)} has no scalar sign.");
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort2 operator %(ushort2 a, ushort2 b)
|
||||
{
|
||||
return new ushort2((ushort)(a.X % b.X), (ushort)(a.Y % b.Y));
|
||||
}
|
||||
|
||||
int IComparable.CompareTo(object? obj) =>
|
||||
throw new NotSupportedException($"{nameof(ushort2)} has no total order.");
|
||||
|
||||
int IComparable<ushort2>.CompareTo(ushort2 other) =>
|
||||
throw new NotSupportedException($"{nameof(ushort2)} has no total order.");
|
||||
|
||||
static bool IComparisonOperators<ushort2, ushort2, bool>.operator <(ushort2 a, ushort2 b) =>
|
||||
throw new NotSupportedException($"{nameof(ushort2)} has no total order.");
|
||||
|
||||
static bool IComparisonOperators<ushort2, ushort2, bool>.operator <=(ushort2 a, ushort2 b) =>
|
||||
throw new NotSupportedException($"{nameof(ushort2)} has no total order.");
|
||||
|
||||
static bool IComparisonOperators<ushort2, ushort2, bool>.operator >(ushort2 a, ushort2 b) =>
|
||||
throw new NotSupportedException($"{nameof(ushort2)} has no total order.");
|
||||
|
||||
static bool IComparisonOperators<ushort2, ushort2, bool>.operator >=(ushort2 a, ushort2 b) =>
|
||||
throw new NotSupportedException($"{nameof(ushort2)} has no total order.");
|
||||
}
|
||||
|
||||
// IComponentwiseComparison + the componentwise predicate masks (no interface to mirror)
|
||||
public partial struct ushort2 : IComponentwiseComparison<ushort2, bool2>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 operator <(ushort2 a, ushort2 b)
|
||||
{
|
||||
return new bool2(a.X < b.X, a.Y < b.Y);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 operator <=(ushort2 a, ushort2 b)
|
||||
{
|
||||
return new bool2(a.X <= b.X, a.Y <= b.Y);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 operator >(ushort2 a, ushort2 b)
|
||||
{
|
||||
return new bool2(a.X > b.X, a.Y > b.Y);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 operator >=(ushort2 a, ushort2 b)
|
||||
{
|
||||
return new bool2(a.X >= b.X, a.Y >= b.Y);
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are zero.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 IsZero(ushort2 value)
|
||||
{
|
||||
return new bool2(value.X == 0, value.Y == 0);
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are an even integral value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 IsEvenInteger(ushort2 value)
|
||||
{
|
||||
return new bool2(ushort.IsEvenInteger(value.X), ushort.IsEvenInteger(value.Y));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are an odd integral value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool2 IsOddInteger(ushort2 value)
|
||||
{
|
||||
return new bool2(ushort.IsOddInteger(value.X), ushort.IsOddInteger(value.Y));
|
||||
}
|
||||
}
|
||||
|
||||
// IUnsignedNumber - a marker, so there is nothing to implement
|
||||
public partial struct ushort2 : IUnsignedNumber<ushort2>;
|
||||
|
|
@ -0,0 +1,210 @@
|
|||
// <auto-generated /> - edit Vector.pack.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct ushort2
|
||||
{
|
||||
public static ushort2 Unpack(in sbyte2 vector, Func<sbyte, ushort> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out ushort2 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ushort2 Unpack(in byte2 vector, Func<byte, ushort> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out ushort2 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ushort2 Unpack(in short2 vector, Func<short, ushort> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out ushort2 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ushort2 Pack(in int2 vector, Func<int, ushort> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out ushort2 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ushort2 Pack(in uint2 vector, Func<uint, ushort> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out ushort2 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ushort2 Pack(in float2 vector, Func<float, ushort> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out ushort2 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ushort2 Pack(in double2 vector, Func<double, ushort> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out ushort2 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ushort2 Unpack(in sbyte2 vector, Unpack.IntegerMixed mode = Numerics.Unpack.IntegerMixed.Cast)
|
||||
{
|
||||
return Unpack(vector, PackUtils.SByte.ToUShort(mode));
|
||||
}
|
||||
|
||||
public static ushort2 Unpack(in byte2 vector, Unpack.Integer mode = Numerics.Unpack.Integer.Cast)
|
||||
{
|
||||
return Unpack(vector, PackUtils.Byte.ToUShort(mode));
|
||||
}
|
||||
|
||||
public static ushort2 Unpack(in short2 vector, Unpack.IntegerMixed mode = Numerics.Unpack.IntegerMixed.Cast)
|
||||
{
|
||||
return Unpack(vector, PackUtils.Short.ToUShort(mode));
|
||||
}
|
||||
|
||||
public static ushort2 Pack(in int2 vector, Pack.IntegerMixed mode = Numerics.Pack.IntegerMixed.Cast)
|
||||
{
|
||||
return Pack(vector, PackUtils.Int.ToUShort(mode));
|
||||
}
|
||||
|
||||
public static ushort2 Pack(in uint2 vector, Pack.Integer mode = Numerics.Pack.Integer.Cast)
|
||||
{
|
||||
return Pack(vector, PackUtils.UInt.ToUShort(mode));
|
||||
}
|
||||
|
||||
public static ushort2 Pack(in float2 vector, Pack.Float mode = Numerics.Pack.Float.Truncate)
|
||||
{
|
||||
return Pack(vector, PackUtils.Float.ToUShort(mode));
|
||||
}
|
||||
|
||||
public static ushort2 Pack(in double2 vector, Pack.Float mode = Numerics.Pack.Float.Truncate)
|
||||
{
|
||||
return Pack(vector, PackUtils.Double.ToUShort(mode));
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<sbyte2> source,
|
||||
Span<ushort2> destination,
|
||||
Func<sbyte, ushort> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<byte2> source,
|
||||
Span<ushort2> destination,
|
||||
Func<byte, ushort> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<short2> source,
|
||||
Span<ushort2> destination,
|
||||
Func<short, ushort> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void PackSpan(
|
||||
in ReadOnlySpan<int2> source,
|
||||
Span<ushort2> destination,
|
||||
Func<int, ushort> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void PackSpan(
|
||||
in ReadOnlySpan<uint2> source,
|
||||
Span<ushort2> destination,
|
||||
Func<uint, ushort> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void PackSpan(
|
||||
in ReadOnlySpan<float2> source,
|
||||
Span<ushort2> destination,
|
||||
Func<float, ushort> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void PackSpan(
|
||||
in ReadOnlySpan<double2> source,
|
||||
Span<ushort2> destination,
|
||||
Func<double, ushort> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<sbyte2> source,
|
||||
Span<ushort2> destination,
|
||||
Unpack.IntegerMixed mode = Numerics.Unpack.IntegerMixed.Cast
|
||||
)
|
||||
{
|
||||
UnpackSpan(source, destination, PackUtils.SByte.ToUShort(mode));
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<byte2> source,
|
||||
Span<ushort2> destination,
|
||||
Unpack.Integer mode = Numerics.Unpack.Integer.Cast
|
||||
)
|
||||
{
|
||||
UnpackSpan(source, destination, PackUtils.Byte.ToUShort(mode));
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<short2> source,
|
||||
Span<ushort2> destination,
|
||||
Unpack.IntegerMixed mode = Numerics.Unpack.IntegerMixed.Cast
|
||||
)
|
||||
{
|
||||
UnpackSpan(source, destination, PackUtils.Short.ToUShort(mode));
|
||||
}
|
||||
|
||||
public static void PackSpan(
|
||||
in ReadOnlySpan<int2> source,
|
||||
Span<ushort2> destination,
|
||||
Pack.IntegerMixed mode = Numerics.Pack.IntegerMixed.Cast
|
||||
)
|
||||
{
|
||||
PackSpan(source, destination, PackUtils.Int.ToUShort(mode));
|
||||
}
|
||||
|
||||
public static void PackSpan(
|
||||
in ReadOnlySpan<uint2> source,
|
||||
Span<ushort2> destination,
|
||||
Pack.Integer mode = Numerics.Pack.Integer.Cast
|
||||
)
|
||||
{
|
||||
PackSpan(source, destination, PackUtils.UInt.ToUShort(mode));
|
||||
}
|
||||
|
||||
public static void PackSpan(
|
||||
in ReadOnlySpan<float2> source,
|
||||
Span<ushort2> destination,
|
||||
Pack.Float mode = Numerics.Pack.Float.Truncate
|
||||
)
|
||||
{
|
||||
PackSpan(source, destination, PackUtils.Float.ToUShort(mode));
|
||||
}
|
||||
|
||||
public static void PackSpan(
|
||||
in ReadOnlySpan<double2> source,
|
||||
Span<ushort2> destination,
|
||||
Pack.Float mode = Numerics.Pack.Float.Truncate
|
||||
)
|
||||
{
|
||||
PackSpan(source, destination, PackUtils.Double.ToUShort(mode));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
// <auto-generated /> - edit Vector.swizzle.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct ushort2
|
||||
{
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the X and Y components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public ushort2 XY
|
||||
{
|
||||
readonly get => this;
|
||||
set => this = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Y and X components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public ushort2 YX
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Y, X);
|
||||
set
|
||||
{
|
||||
Y = value.X;
|
||||
X = value.Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial struct ushort2
|
||||
{
|
||||
/// <summary>
|
||||
/// The Red component of the vector (synonym for X).
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public ushort R
|
||||
{
|
||||
readonly get => X;
|
||||
set => X = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Green component of the vector (synonym for Y).
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public ushort G
|
||||
{
|
||||
readonly get => Y;
|
||||
set => Y = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Red and Green components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public ushort2 RG
|
||||
{
|
||||
readonly get => this;
|
||||
set => this = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Green and Red components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public ushort2 GR
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Y, X);
|
||||
set
|
||||
{
|
||||
G = value.R;
|
||||
R = value.G;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue