Watch
2
0
Fork
You've already forked raylib-cs
0

Removed extensions class

Removed the "RaylibExtensions.cs" file...
This commit is contained in:
Matorio 2025-08-10 15:58:41 -05:00
commit e2bbeee1b2
2 changed files with 11 additions and 92 deletions

View file

@ -1,87 +0,0 @@
using System.Collections.Generic;
using System.Numerics;
namespace Raylib_cs;
public static class RaylibExtensions
{
public static void DrawLines(this IEnumerable<Vector2> points, Color color)
{
Vector2[] pointArray = System.Linq.Enumerable.ToArray<Vector2>(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
}

View file

@ -104,7 +104,7 @@ public struct Color
/// <summary>
/// <inheritdoc cref="Color(byte, byte, byte)"/>.
/// Accepts <see cref="float"/>'s, upscales and clamps them to the range 0..255.
/// Accepts <see cref="float"/>'s, upscales and clamps them to the range 0...255.
/// Then they are converted to <see cref="byte"/>'s by rounding.
/// </summary>
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}}}";