Code/Util/Math/Modulo.cs
namespace Nodebox.Util.Math;
public sealed class Modulo : BinaryOperator {
public override Dictionary<(Type, Type), Func<object, object, object>> BaseLookup => new() {
{ (typeof(float), typeof(float)), (a, b) => (float)a % (float)b },
{ (typeof(double), typeof(double)), (a, b) => (double)a % (double)b },
{ (typeof(int), typeof(int)), (a, b) => (int)a % (int)b },
{ (typeof(uint), typeof(uint)), (a, b) => (uint)a % (uint)b },
{ (typeof(long), typeof(long)), (a, b) => (long)a % (long)b },
{ (typeof(ulong), typeof(ulong)), (a, b) => (ulong)a % (ulong)b },
{ (typeof(short), typeof(short)), (a, b) => (short)a % (short)b },
{ (typeof(ushort), typeof(ushort)), (a, b) => (ushort)a % (ushort)b },
{ (typeof(sbyte), typeof(sbyte)), (a, b) => (sbyte)a % (sbyte)b },
{ (typeof(byte), typeof(byte)), (a, b) => (byte)a % (byte)b },
{ (typeof(Vector2), typeof(Vector2)), (a, b) => new Vector2 (
((Vector2)a).x % ((Vector2)b).x,
((Vector2)a).y % ((Vector2)b).y
) },
{ (typeof(Vector3), typeof(Vector3)), (a, b) => new Vector3 (
((Vector3)a).x % ((Vector3)b).x,
((Vector3)a).y % ((Vector3)b).y,
((Vector3)a).z % ((Vector3)b).z
) },
{ (typeof(Vector4), typeof(Vector4)), (a, b) => new Vector4 (
((Vector4)a).x % ((Vector4)b).x,
((Vector4)a).y % ((Vector4)b).y,
((Vector4)a).z % ((Vector4)b).z,
((Vector4)a).w % ((Vector4)b).w
) },
{ (typeof(Vector2Int), typeof(Vector2Int)), (a, b) => new Vector2Int (
((Vector2Int)a).x % ((Vector2Int)b).x,
((Vector2Int)a).y % ((Vector2Int)b).y
) },
{ (typeof(Vector3Int), typeof(Vector3Int)), (a, b) => new Vector3Int (
((Vector3Int)a).x % ((Vector3Int)b).x,
((Vector3Int)a).y % ((Vector3Int)b).y,
((Vector3Int)a).z % ((Vector3Int)b).z
) },
{ (typeof(Angles), typeof(Angles)), (a, b) => new Angles(
((Angles)a).pitch % ((Angles)b).pitch,
((Angles)a).yaw % ((Angles)b).yaw,
((Angles)a).roll % ((Angles)b).roll
) },
// { (typeof(Rotation), typeof(Rotation)), (a, b) => (Rotation)a % (Rotation)b },
{ (typeof(Color), typeof(Color)), (a, b) => new Color(
((Color)a).r % ((Color)b).r,
((Color)a).g % ((Color)b).g,
((Color)a).b % ((Color)b).b,
((Color)a).a % ((Color)b).a
) },
// %% { (typeof(Rect), typeof(Rect)), (a, b) => (Rect)a % (Rect)b },
// %% { (typeof(RectInt), typeof(RectInt)), (a, b) => (RectInt)a % (RectInt)b },
};
}