Struct Color32
- Namespace
- LMKit.Graphics.Primitives
- Assembly
- LM-Kit.NET.dll
public readonly struct Color32 : IEquatable<Color32>- Implements
- Inherited Members
Examples
// Opaque white
var white = new Color32(255, 255, 255);
// Semi-transparent red
var red50 = new Color32(255, 0, 0, 128);
// Pack/unpack RRGGBBAA
int rgba = red50.ToRgba();          // 0xFF000080
var again = Color32.FromRgba(rgba); // equal to red50Remarks
Each component is stored as a byte in the range 0..255.
Packed integer format: 0xRRGGBBAA (alpha in the least significant byte).
Constructors
- Color32(byte)
- Initializes a new opaque Color32 from a single grayscale value. 
- Color32(byte, byte, byte)
- Initializes a new opaque Color32 from red, green, and blue components (alpha=255). 
- Color32(byte, byte, byte, byte)
- Initializes a new Color32 from red, green, blue, and alpha components. 
Fields
- A
- Alpha channel (0..255). 0=fully transparent, 255=fully opaque. 
- B
- Blue channel intensity (0..255). 
- G
- Green channel intensity (0..255). 
- R
- Red channel intensity (0..255). 
Methods
- Deconstruct(out byte, out byte, out byte, out byte)
- Deconstructs the color into (r, g, b, a). 
- FromBgr(int)
- Creates an opaque Color32 from a packed 24-bit BGR integer ( - 0xBBGGRR).
- FromBgr(int, byte)
- Creates a Color32 from a packed 24-bit BGR integer ( - 0xBBGGRR) and an alpha.
- FromRgb(int)
- Creates an opaque Color32 from a packed 24-bit RGB integer ( - 0xRRGGBB).
- FromRgb(int, byte)
- Creates a Color32 from a packed 24-bit RGB integer ( - 0xRRGGBB) and an alpha.
- FromRgba(int)
- Creates a Color32 from a packed 32-bit RGBA integer ( - 0xRRGGBBAA).
- GetLuminance()
- Computes the perceived brightness (luminance) of this color as a single 8-bit grayscale value. Uses Rec. 601 luma weights: 0.299 * R + 0.587 * G + 0.114 * B. 
- ToRgb()
- Converts this color to a packed 24-bit RGB integer ( - 0xRRGGBB), dropping alpha.
- ToRgba()
- Converts this color to a packed 32-bit RGBA integer ( - 0xRRGGBBAA).
- WithAlpha(byte)
- Returns a copy of this color with a different alpha.