From 2e07b0ffc99575b974b890d35f6c8cbd3585ff59 Mon Sep 17 00:00:00 2001 From: "H. Utku Maden" Date: Fri, 23 Jun 2023 22:53:22 +0300 Subject: [PATCH] Add pretty colors and new functions into the math types. --- Quik/QuikGeometry.cs | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/Quik/QuikGeometry.cs b/Quik/QuikGeometry.cs index 2aa3d7f..28b051d 100644 --- a/Quik/QuikGeometry.cs +++ b/Quik/QuikGeometry.cs @@ -130,6 +130,15 @@ namespace Quik A = (byte)((hexCode >> 0 ) & 0xFF); } 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); } /// @@ -214,9 +223,17 @@ namespace Quik { float T = 1 - t; return - 3 * T * T * (ControlA - Start) + - 6 * T * t * (ControlB - ControlA) + - 3 * t * t * (End - ControlB); + ( + 3 * T * T * (ControlA - Start) + + 6 * T * t * (ControlB - ControlA) + + 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.Y = endY; } + + public QuikVec2 Normal() + { + QuikVec2 tangent = Tangent(); + return new QuikVec2(-tangent.Y, tangent.X); + } + public QuikVec2 Tangent() + { + return (End - Start).Normalize(); + } } ///