Api Color32
struct

Color32

public sealed struct Color32

A 32bit color, commonly used by things like vertex buffers. The functionality on this is purposely left minimal so we're encouraged to use the regular Color struct.

Constructors

Color32(Byte r, Byte g, Byte b, Byte a)

Initialize a color with each component set to given values, in range [0,255]

Color32(Byte all)

Initialize a color with each component set to given value, even alpha.

all — A number in range [0-255]
Color32(UInt32 raw)

Initialize from an integer of the form 0xAABBGGRR.

raw — Packed integer of the form 0xAABBGGRR.
Color32(Int32 raw)

Initialize from an integer of the form 0xAABBGGRR.

raw — Packed integer of the form 0xAABBGGRR.

Properties

Name Type Description
White static Color32 A constant representing a fully opaque color white.
Black static Color32 A constant representing a fully opaque color black.
Transparent static Color32 A constant representing a fully transparent color.
Hex String String representation of the form "#RRGGBB[AA]".
Rgba String String representation in the form of rgba( r, g, b, a ) css function notation.
Rgb String String representation in the form of rgb( r, g, b ) css function notation.
RgbaInt UInt32 Integer representation of the form 0xRRGGBBAA.
RgbInt UInt32 Integer representation of the form 0xRRGGBB.
RawInt UInt32 Integer representation of the form 0xAABBGGRR as used by native code.

Methods

static Color32 FromRgb(UInt32 rgb)

Converts an integer of the form 0xRRGGBB into the color #RRGGBB with 100% alpha.

rgb — Integer between 0x000000 and 0xffffff representing a color.
static Color32 FromRgba(UInt32 rgba)

Converts an integer of the form 0xRRGGBBAA into the color #RRGGBBAA.

rgba — Integer between 0x00000000 and 0xffffffff representing a color with alpha.
Color ToColor()

Convert this object to Color.

returns — The converted color struct.
Color ToColor(Boolean srgb)

Convert this object to Color.

srgb — If true we'll convert from the srgb color space to linear
returns — The converted color struct.
static Color32 Min(Color32 a, Color32 b)

Returns a new color with each component being the minimum of the 2 given colors.

a — Color A
b — Color B
returns — The new color with minimum values.
static Color32 Max(Color32 a, Color32 b)

Returns a new color with each component being the maximum of the 2 given colors.

a — Color A
b — Color B
returns — The new color with maximum values.
Void Write(BinaryWriter writer)

Write this color to a binary writer.

writer — Writer to write to.
static Color32 Read(BinaryReader reader)

Read a color from binary reader.

reader — Reader to read from.
returns — The read color.
static Color32? Parse(String value)

Parse a string to a color, in format "255 255 255 255" or "255,255,255". Alpha is optional.

value — The value to parse.
returns — The color parsed from the string, or null if we failed to do so.

Fields

Name Type Description
r Byte The red color component, in range of 0-255.
g Byte The green color component, in range of 0-255.
b Byte The blue color component, in range of 0-255.
a Byte The alpha/transparency color component, in range of 0 (fully transparent) to 255 (fully opaque).
Assembly: Sandbox.System Full Name: Color32