Skip to main content

Color Struct

Package: GHIElectronics.Endpoint.Drawing
Namespace: GHIElectronics.Endpoint.Drawing

A 32-bit color with 8 bits each of alpha, red, green, blue. Canvas maps it to its PixelFormat at draw time: Monochrome treats non-zero as "lit", Rgb565 drops the low bits, Rgb888 drops alpha, Argb8888 keeps everything.

public readonly struct Color

Constructors​

Color(byte r, byte g, byte b)​

public Color(byte r, byte g, byte b)

Opaque color from R/G/B.

Color(byte r, byte g, byte b, byte a)​

public Color(byte r, byte g, byte b, byte a)

Color from R/G/B and alpha.

Properties​

R​

public byte R { get; }

Red component, 0..255.

Returns byte

G​

public byte G { get; }

Green component, 0..255.

Returns byte

B​

public byte B { get; }

Blue component, 0..255.

Returns byte

A​

public byte A { get; }

Alpha, 0 (transparent) .. 255 (opaque). Only Argb8888 canvases use it.

Returns byte

Methods​

FromArgb(uint argb)​

public static Color FromArgb(uint argb)

Color from a 0xAARRGGBB value.

Returns Color

FromRgb(uint rgb)​

public static Color FromRgb(uint rgb)

Color from a 0xRRGGBB value, opaque.

Returns Color

Named Colors​

Static properties. Names match System.Drawing / CSS where they overlap.

NameValue
Transparent0x00000000
Black0x000000
White0xFFFFFF
Red0xFF0000
Green0x00FF00
Blue0x0000FF
Yellow0xFFFF00
Cyan0x00FFFF
Magenta0xFF00FF
Navy0x000080
Maroon0x800000
Olive0x808000
Gray0x808080
Silver0xC0C0C0
Orange0xFFA500