Add float color structure.

This commit is contained in:
H. Utku Maden 2023-07-02 10:38:19 +03:00
parent 8e2db62e56
commit 98883db604

@ -139,8 +139,62 @@ namespace Quik
public static readonly QColor Cyan = new QColor(0, 255, 255, 255);
public static readonly QColor Magenta = new QColor(255, 0, 255, 255);
public static readonly QColor White = new QColor(255, 255, 255, 255);
public static explicit operator QColorF(QColor a)
{
return new QColorF(a.R/255.0f, a.G/255.0f, a.B/255.0f, a.A/255.0f);
}
}
public struct QColorF
{
/// <summary>
/// Red channel.
/// </summary>
public float R;
/// <summary>
/// Green channel.
/// </summary>
public float G;
/// <summary>
/// Blue channel.
/// </summary>
public float B;
/// <summary>
/// Alpha channel.
/// </summary>
public float A;
public QColorF(float r, float g, float b, float a)
{
R = r; G = g; B = b; A = a;
}
public QColorF(float r, float g, float b) : this(r, g, b, 1.0f) { }
public QColorF(uint hexCode)
{
R = ((hexCode >> 24) & 0xFF)/255.0f;
G = ((hexCode >> 16) & 0xFF)/255.0f;
B = ((hexCode >> 8 ) & 0xFF)/255.0f;
A = ((hexCode >> 0 ) & 0xFF)/255.0f;
}
public QColorF(int hexCode) : this((uint)hexCode) { }
public static readonly QColorF Black = new QColorF(0, 0, 0, 1.0f);
public static readonly QColorF Red = new QColorF(1.0f, 0, 0, 1.0f);
public static readonly QColorF Green = new QColorF(0, 1, 0, 1);
public static readonly QColorF Blue = new QColorF(0, 0, 1, 1);
public static readonly QColorF Yellow = new QColorF(1, 1, 0, 1);
public static readonly QColorF Cyan = new QColorF(0, 1, 1, 1);
public static readonly QColorF Magenta = new QColorF(1, 0, 1, 1);
public static readonly QColorF White = new QColorF(1, 1, 1, 1);
public static explicit operator QColor(QColorF a)
{
return new QColor((byte)(a.R * 255), (byte)(a.G * 255), (byte)(a.B * 255), (byte)(a.A * 255));
}
}
/// <summary>
/// A bezier curve segment.
/// </summary>