Add pretty colors and new functions into the math types.

This commit is contained in:
H. Utku Maden 2023-06-23 22:53:22 +03:00
parent a50650e54a
commit 2e07b0ffc9

@ -130,6 +130,15 @@ namespace Quik
A = (byte)((hexCode >> 0 ) & 0xFF); A = (byte)((hexCode >> 0 ) & 0xFF);
} }
public QuikColor(int hexCode) : this((uint)hexCode) { } public QuikColor(int hexCode) : this((uint)hexCode) { }
public static readonly QuikColor Black = new QuikColor(0, 0, 0, 255);
public static readonly QuikColor Red = new QuikColor(255, 0, 0, 255);
public static readonly QuikColor Green = new QuikColor(0, 255, 0, 255);
public static readonly QuikColor Blue = new QuikColor(0, 0, 255, 255);
public static readonly QuikColor Yellow = new QuikColor(255, 255, 0, 255);
public static readonly QuikColor Cyan = new QuikColor(0, 255, 255, 255);
public static readonly QuikColor Magenta = new QuikColor(255, 0, 255, 255);
public static readonly QuikColor White = new QuikColor(255, 255, 255, 255);
} }
/// <summary> /// <summary>
@ -214,9 +223,17 @@ namespace Quik
{ {
float T = 1 - t; float T = 1 - t;
return return
(
3 * T * T * (ControlA - Start) + 3 * T * T * (ControlA - Start) +
6 * T * t * (ControlB - ControlA) + 6 * T * t * (ControlB - ControlA) +
3 * t * t * (End - ControlB); 3 * t * t * (End - ControlB)
).Normalize();
}
internal QuikVec2 GetBezierNormal(float t)
{
QuikVec2 tangent = GetBezierTangent(t);
return new QuikVec2(-tangent.Y, tangent.X);
} }
} }
@ -249,6 +266,16 @@ namespace Quik
End.X = endX; End.X = endX;
End.Y = endY; End.Y = endY;
} }
public QuikVec2 Normal()
{
QuikVec2 tangent = Tangent();
return new QuikVec2(-tangent.Y, tangent.X);
}
public QuikVec2 Tangent()
{
return (End - Start).Normalize();
}
} }
/// <summary> /// <summary>