| | | 1 | | //======================================================================= |
| | | 2 | | // GravitasDiagnosticColor.cs |
| | | 3 | | //======================================================================= |
| | | 4 | | // MIT License, Copyright (c) 2026–present David Oravsky (mrdav30) |
| | | 5 | | // See LICENSE file in the project root for full license information. |
| | | 6 | | //======================================================================= |
| | | 7 | | |
| | | 8 | | namespace Gravitas.Diagnostics; |
| | | 9 | | |
| | | 10 | | /// <summary> |
| | | 11 | | /// Engine-agnostic 8-bit RGBA color for diagnostic draw commands. |
| | | 12 | | /// </summary> |
| | | 13 | | public readonly struct GravitasDiagnosticColor |
| | | 14 | | { |
| | | 15 | | /// <summary>Creates a color from red, green, blue, and alpha components.</summary> |
| | | 16 | | public GravitasDiagnosticColor(byte r, byte g, byte b, byte a = byte.MaxValue) |
| | | 17 | | { |
| | 149 | 18 | | R = r; |
| | 149 | 19 | | G = g; |
| | 149 | 20 | | B = b; |
| | 149 | 21 | | A = a; |
| | 149 | 22 | | } |
| | | 23 | | |
| | | 24 | | /// <summary>Gets the red component.</summary> |
| | | 25 | | public byte R { get; } |
| | | 26 | | |
| | | 27 | | /// <summary>Gets the green component.</summary> |
| | | 28 | | public byte G { get; } |
| | | 29 | | |
| | | 30 | | /// <summary>Gets the blue component.</summary> |
| | | 31 | | public byte B { get; } |
| | | 32 | | |
| | | 33 | | /// <summary>Gets the alpha component.</summary> |
| | | 34 | | public byte A { get; } |
| | | 35 | | |
| | | 36 | | /// <summary>Gets the packed RGBA value with red in the most significant byte.</summary> |
| | | 37 | | public uint Rgba => |
| | 7 | 38 | | ((uint)R << 24) |
| | 7 | 39 | | | ((uint)G << 16) |
| | 7 | 40 | | | ((uint)B << 8) |
| | 7 | 41 | | | A; |
| | | 42 | | |
| | | 43 | | /// <summary>Gets opaque white.</summary> |
| | 4 | 44 | | public static GravitasDiagnosticColor White => new(byte.MaxValue, byte.MaxValue, byte.MaxValue); |
| | | 45 | | |
| | | 46 | | /// <summary>Gets opaque red.</summary> |
| | 5 | 47 | | public static GravitasDiagnosticColor Red => new(byte.MaxValue, 0, 0); |
| | | 48 | | |
| | | 49 | | /// <summary>Gets opaque green.</summary> |
| | 9 | 50 | | public static GravitasDiagnosticColor Green => new(0, byte.MaxValue, 0); |
| | | 51 | | |
| | | 52 | | /// <summary>Gets opaque blue.</summary> |
| | 6 | 53 | | public static GravitasDiagnosticColor Blue => new(0, 0, byte.MaxValue); |
| | | 54 | | |
| | | 55 | | /// <summary>Gets opaque yellow.</summary> |
| | 8 | 56 | | public static GravitasDiagnosticColor Yellow => new(byte.MaxValue, byte.MaxValue, 0); |
| | | 57 | | |
| | | 58 | | /// <summary>Gets opaque cyan.</summary> |
| | 115 | 59 | | public static GravitasDiagnosticColor Cyan => new(0, byte.MaxValue, byte.MaxValue); |
| | | 60 | | } |