From e2bbeee1b294b5e7cdda1ae7b92ec18f65977dd5 Mon Sep 17 00:00:00 2001 From: Matorio <209939889+Matorio@users.noreply.github.com> Date: Sun, 10 Aug 2025 15:58:41 -0500 Subject: [PATCH] Removed extensions class Removed the "RaylibExtensions.cs" file... --- Raylib-cs/interop/RaylibExtensions.cs | 87 --------------------------- Raylib-cs/types/Color.cs | 16 +++-- 2 files changed, 11 insertions(+), 92 deletions(-) delete mode 100644 Raylib-cs/interop/RaylibExtensions.cs diff --git a/Raylib-cs/interop/RaylibExtensions.cs b/Raylib-cs/interop/RaylibExtensions.cs deleted file mode 100644 index a1c449d..0000000 --- a/Raylib-cs/interop/RaylibExtensions.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System.Collections.Generic; -using System.Numerics; - -namespace Raylib_cs; - -public static class RaylibExtensions -{ - public static void DrawLines(this IEnumerable points, Color color) - { - Vector2[] pointArray = System.Linq.Enumerable.ToArray(points); - Raylib.DrawLineStrip(pointArray, pointArray.Length, color); - } - - public static void Log(this TraceLogLevel logLevel, string message) - { - Raylib.TraceLog(logLevel, message); - } - - public static byte Lerp(this byte a, byte b, float t) - { - return (byte)(a + (b - a) * t); - } - - #region Vector - - public static void Normalize(this ref Vector2 vector) - { - vector = Raymath.Vector2Normalize(vector); - } - - public static void Normalize(this ref Vector3 vector) - { - vector = Raymath.Vector3Normalize(vector); - } - - public static void Add(this ref Vector2 vector, float value) - { - vector = Raymath.Vector2AddValue(vector, value); - } - - public static void Add(this ref Vector3 vector, float value) - { - vector = Raymath.Vector3AddValue(vector, value); - } - - public static void Add(this ref Vector2 vector, Vector2 value) - { - vector = Raymath.Vector2Add(vector, value); - } - - public static void Add(this ref Vector3 vector, Vector3 value) - { - vector = Raymath.Vector3Add(vector, value); - } - - public static float GetDistance(this Vector2 v1, Vector2 v2) - { - return Raymath.Vector2Distance(v1, v2); - } - - public static float GetDistance(this Vector3 v1, Vector3 v2) - { - return Raymath.Vector3Distance(v1, v2); - } - - public static Vector2 Lerp(this Vector2 v1, Vector2 v2, float amount) - { - return Raymath.Vector2Lerp(v1, v2, amount); - } - - public static Vector3 Lerp(this Vector3 v1, Vector3 v2, float amount) - { - return Raymath.Vector3Lerp(v1, v2, amount); - } - - public static Vector2 MoveTowards(this Vector2 v1, Vector2 v2, float t) - { - return Raymath.Vector2MoveTowards(v1, v2, t); - } - - public static Vector3 MoveTowards(this Vector3 v1, Vector3 v2, float t) - { - return Raymath.Vector3MoveTowards(v1, v2, t); - } - - #endregion -} diff --git a/Raylib-cs/types/Color.cs b/Raylib-cs/types/Color.cs index 5d73bef..d696152 100644 --- a/Raylib-cs/types/Color.cs +++ b/Raylib-cs/types/Color.cs @@ -104,7 +104,7 @@ public struct Color /// /// . - /// Accepts 's, upscales and clamps them to the range 0..255. + /// Accepts 's, upscales and clamps them to the range 0...255. /// Then they are converted to 's by rounding. /// public Color(float r, float g, float b) @@ -209,13 +209,19 @@ public struct Color public static Color Lerp(Color origin, Color target, float t) { - byte r = origin.R.Lerp(target.R, t); - byte g = origin.G.Lerp(target.G, t); - byte b = origin.B.Lerp(target.B, t); - byte a = origin.A.Lerp(target.A, t); + byte r = LerpB(origin.R, target.R, t); + byte g = LerpB(origin.R, target.G, t); + byte b = LerpB(origin.R, target.B, t); + byte a = LerpB(origin.R, target.A, t); return new Color(r, g, b, a); } + // Lerp byte + private static byte LerpB(byte a, byte b, float t) + { + return (byte)(a + (b - a) * t); + } + public readonly override string ToString() { return $"{{R:{R} G:{G} B:{B} A:{A}}}";