Class TinyColor
A lightweight color struct using byte values for R, G, B, and A components (0-255). Provides conversions, predefined colors, and utility functions for color manipulation.
public class TinyColor
- Inheritance
-
TinyColor
- Inherited Members
- Extension Methods
Constructors
TinyColor(byte, byte, byte)
Initializes a new instance of the TinyColor struct with RGB components and full opacity (alpha = 255).
public TinyColor(byte red, byte green, byte blue)
Parameters
redbyteThe red component (0-255).
greenbyteThe green component (0-255).
bluebyteThe blue component (0-255).
TinyColor(byte, byte, byte, byte)
Initializes a new instance of the TinyColor struct with RGBA components.
public TinyColor(byte red, byte green, byte blue, byte alpha)
Parameters
redbyteThe red component (0-255).
greenbyteThe green component (0-255).
bluebyteThe blue component (0-255).
alphabyteThe alpha (transparency) component (0-255).
Fields
a
The Alpha (transparency) component of the color (0-255).
public readonly byte a
Field Value
b
The Blue component of the color (0-255).
public readonly byte b
Field Value
black
The black predefined color constant.
public static readonly TinyColor black
Field Value
bloodRed
The bloodRed predefined color constant.
public static readonly TinyColor bloodRed
Field Value
blue
The blue predefined color constant.
public static readonly TinyColor blue
Field Value
bronze
The bronze predefined color constant.
public static readonly TinyColor bronze
Field Value
charcoal
The charcoal predefined color constant.
public static readonly TinyColor charcoal
Field Value
chartreuse
The chartreuse predefined color constant.
public static readonly TinyColor chartreuse
Field Value
chocolate
The chocolate predefined color constant.
public static readonly TinyColor chocolate
Field Value
coral
The coral predefined color constant.
public static readonly TinyColor coral
Field Value
crimson
The crimson predefined color constant.
public static readonly TinyColor crimson
Field Value
cyan
The cyan predefined color constant.
public static readonly TinyColor cyan
Field Value
darkGrey
The darkGrey predefined color constant.
public static readonly TinyColor darkGrey
Field Value
darkSlateGreen
The darkSlateGreen predefined color constant.
public static readonly TinyColor darkSlateGreen
Field Value
dimGrey
The dimGrey predefined color constant.
public static readonly TinyColor dimGrey
Field Value
forestGreen
The forestGreen predefined color constant.
public static readonly TinyColor forestGreen
Field Value
g
The Green component of the color (0-255).
public readonly byte g
Field Value
gainsboro
The gainsboro predefined color constant.
public static readonly TinyColor gainsboro
Field Value
gold
The gold predefined color constant.
public static readonly TinyColor gold
Field Value
goldenrod
The goldenrod predefined color constant.
public static readonly TinyColor goldenrod
Field Value
green
The green predefined color constant.
public static readonly TinyColor green
Field Value
hotPink
The hotPink predefined color constant.
public static readonly TinyColor hotPink
Field Value
indigo
The indigo predefined color constant.
public static readonly TinyColor indigo
Field Value
lavender
The lavender predefined color constant.
public static readonly TinyColor lavender
Field Value
lightGrey
The lightGrey predefined color constant.
public static readonly TinyColor lightGrey
Field Value
limeGreen
The limeGreen predefined color constant.
public static readonly TinyColor limeGreen
Field Value
magenta
The magenta predefined color constant.
public static readonly TinyColor magenta
Field Value
maroon
The maroon predefined color constant.
public static readonly TinyColor maroon
Field Value
midnightBlue
The midnightBlue predefined color constant.
public static readonly TinyColor midnightBlue
Field Value
navy
The navy predefined color constant.
public static readonly TinyColor navy
Field Value
offWhite
The offWhite predefined color constant.
public static readonly TinyColor offWhite
Field Value
olive
The olive predefined color constant.
public static readonly TinyColor olive
Field Value
orange
The orange predefined color constant.
public static readonly TinyColor orange
Field Value
orchid
The orchid predefined color constant.
public static readonly TinyColor orchid
Field Value
plum
The plum predefined color constant.
public static readonly TinyColor plum
Field Value
r
The Red component of the color (0-255).
public readonly byte r
Field Value
red
The red predefined color constant.
public static readonly TinyColor red
Field Value
royalBlue
The royalBlue predefined color constant.
public static readonly TinyColor royalBlue
Field Value
saddleBrown
The saddleBrown predefined color constant.
public static readonly TinyColor saddleBrown
Field Value
seaGreen
The seaGreen predefined color constant.
public static readonly TinyColor seaGreen
Field Value
sienna
The sienna predefined color constant.
public static readonly TinyColor sienna
Field Value
silver
The silver predefined color constant.
public static readonly TinyColor silver
Field Value
skyBlue
The skyBlue predefined color constant.
public static readonly TinyColor skyBlue
Field Value
slateGrey
The slateGrey predefined color constant.
public static readonly TinyColor slateGrey
Field Value
steelBlue
The steelBlue predefined color constant.
public static readonly TinyColor steelBlue
Field Value
teal
The teal predefined color constant.
public static readonly TinyColor teal
Field Value
transparent
The transparent predefined color constant.
public static readonly TinyColor transparent
Field Value
turquoise
The turquoise predefined color constant.
public static readonly TinyColor turquoise
Field Value
violet
The violet predefined color constant.
public static readonly TinyColor violet
Field Value
wheat
The wheat predefined color constant.
public static readonly TinyColor wheat
Field Value
white
The white predefined color constant.
public static readonly TinyColor white
Field Value
yellow
The yellow predefined color constant.
public static readonly TinyColor yellow
Field Value
Methods
FromString(string)
Parses a string into a TinyColor object. Expected input format: "RGBA(R, G, B, A)" where R, G, B, A are byte values (0-255).
public static TinyColor FromString(string colorString)
Parameters
colorStringstringThe string to parse (e.g., "RGBA(128, 64, 255, 100)").
Returns
FromUnityColor(Color)
Creates a TinyColor from a Unity UnityEngine.Color.
public static TinyColor FromUnityColor(Color color)
Parameters
colorColorThe Unity Color to convert.
Returns
- TinyColor
A TinyColor representation of the Unity Color.
GenerateAlphaSpectrum(int, int)
Generates a horizontal alpha spectrum where RGB fades from white to black as alpha increases.
public static Texture2D GenerateAlphaSpectrum(int width, int height)
Parameters
Returns
- Texture2D
A new UnityEngine.Texture2D representing the alpha spectrum.
GenerateBlueSpectrum(float, float, int, int)
Generates a horizontal blue color spectrum with specified red, green, and full alpha values.
public static Texture2D GenerateBlueSpectrum(float red, float green, int width, int height)
Parameters
redfloatThe red component value (0.0f-1.0f).
greenfloatThe green component value (0.0f-1.0f).
widthintThe width of the generated texture.
heightintThe height of the generated texture.
Returns
- Texture2D
A new UnityEngine.Texture2D representing the blue spectrum.
GenerateBlueSpectrum(float, float, float, int, int)
Generates a horizontal blue color spectrum with specified red, green, and alpha values.
public static Texture2D GenerateBlueSpectrum(float red, float green, float alpha, int width, int height)
Parameters
redfloatThe red component value (0.0f-1.0f).
greenfloatThe green component value (0.0f-1.0f).
alphafloatThe alpha value for the generated colors (0.0f-1.0f).
widthintThe width of the generated texture.
heightintThe height of the generated texture.
Returns
- Texture2D
A new UnityEngine.Texture2D representing the blue spectrum.
GenerateBrightnessSpectrum(int, int)
Generates a horizontal brightness spectrum (grayscale gradient) with an alpha of 1.0f.
public static Texture2D GenerateBrightnessSpectrum(int width, int height)
Parameters
Returns
- Texture2D
A new UnityEngine.Texture2D representing the brightness spectrum.
GenerateColorSpectrum(int, int)
Generates a horizontal color spectrum (hue gradient) with full saturation and value, and an alpha of 1.0f.
public static Texture2D GenerateColorSpectrum(int width, int height)
Parameters
Returns
- Texture2D
A new UnityEngine.Texture2D representing the color spectrum.
GenerateColorSpectrum(float, int, int)
Generates a horizontal color spectrum (hue gradient) with full saturation and value, and a specified alpha.
public static Texture2D GenerateColorSpectrum(float alpha, int width, int height)
Parameters
alphafloatThe alpha value for the generated colors (0.0f-1.0f).
widthintThe width of the generated texture.
heightintThe height of the generated texture.
Returns
- Texture2D
A new UnityEngine.Texture2D representing the color spectrum.
GenerateGreenSpectrum(float, float, int, int)
Generates a horizontal green color spectrum with specified red, blue, and full alpha values.
public static Texture2D GenerateGreenSpectrum(float red, float blue, int width, int height)
Parameters
redfloatThe red component value (0.0f-1.0f).
bluefloatThe blue component value (0.0f-1.0f).
widthintThe width of the generated texture.
heightintThe height of the generated texture.
Returns
- Texture2D
A new UnityEngine.Texture2D representing the green spectrum.
GenerateGreenSpectrum(float, float, float, int, int)
Generates a horizontal green color spectrum with specified red, blue, and alpha values.
public static Texture2D GenerateGreenSpectrum(float red, float blue, float alpha, int width, int height)
Parameters
redfloatThe red component value (0.0f-1.0f).
bluefloatThe blue component value (0.0f-1.0f).
alphafloatThe alpha value for the generated colors (0.0f-1.0f).
widthintThe width of the generated texture.
heightintThe height of the generated texture.
Returns
- Texture2D
A new UnityEngine.Texture2D representing the green spectrum.
GenerateHSVTexture(float, int, int)
Generates an HSV texture (saturation vs. value) for a given hue with an alpha of 1.0f. X-axis represents Value (brightness), Y-axis represents Saturation.
public static Texture2D GenerateHSVTexture(float hue, int width, int height)
Parameters
huefloatThe hue value for the texture (0-360 degrees).
widthintThe width of the generated texture (represents value).
heightintThe height of the generated texture (represents saturation).
Returns
- Texture2D
A new UnityEngine.Texture2D representing the HSV color space.
GenerateHSVTexture(float, float, int, int)
Generates an HSV texture (saturation vs. value) for a given hue with a specified alpha. X-axis represents Value (brightness), Y-axis represents Saturation.
public static Texture2D GenerateHSVTexture(float hue, float alpha, int width, int height)
Parameters
huefloatThe hue value for the texture (0-360 degrees).
alphafloatThe alpha value for the generated colors (0.0f-1.0f).
widthintThe width of the generated texture (represents value).
heightintThe height of the generated texture (represents saturation).
Returns
- Texture2D
A new UnityEngine.Texture2D representing the HSV color space.
GenerateRedSpectrum(float, float, int, int)
Generates a horizontal red color spectrum with specified green, blue, and full alpha values.
public static Texture2D GenerateRedSpectrum(float green, float blue, int width, int height)
Parameters
greenfloatThe green component value (0.0f-1.0f).
bluefloatThe blue component value (0.0f-1.0f).
widthintThe width of the generated texture.
heightintThe height of the generated texture.
Returns
- Texture2D
A new UnityEngine.Texture2D representing the red spectrum.
GenerateRedSpectrum(float, float, float, int, int)
Generates a horizontal red color spectrum with specified green, blue, and alpha values.
public static Texture2D GenerateRedSpectrum(float green, float blue, float alpha, int width, int height)
Parameters
greenfloatThe green component value (0.0f-1.0f).
bluefloatThe blue component value (0.0f-1.0f).
alphafloatThe alpha value for the generated colors (0.0f-1.0f).
widthintThe width of the generated texture.
heightintThe height of the generated texture.
Returns
- Texture2D
A new UnityEngine.Texture2D representing the red spectrum.
GenerateSaturationSpectrum(float, float, int, int)
Generates a horizontal saturation spectrum (saturation gradient) for a given hue and value, with an alpha of 1.0f.
public static Texture2D GenerateSaturationSpectrum(float hue, float value, int width, int height)
Parameters
huefloatThe hue value for the spectrum (0-360 degrees).
valuefloatThe value (brightness) for the spectrum (0.0f-1.0f).
widthintThe width of the generated texture.
heightintThe height of the generated texture.
Returns
- Texture2D
A new UnityEngine.Texture2D representing the saturation spectrum.
GenerateSaturationSpectrum(float, float, float, int, int)
Generates a horizontal saturation spectrum (saturation gradient) for a given hue and value, with a specified alpha.
public static Texture2D GenerateSaturationSpectrum(float hue, float value, float alpha, int width, int height)
Parameters
huefloatThe hue value for the spectrum (0-360 degrees).
valuefloatThe value (brightness) for the spectrum (0.0f-1.0f).
alphafloatThe alpha value for the generated colors (0.0f-1.0f).
widthintThe width of the generated texture.
heightintThe height of the generated texture.
Returns
- Texture2D
A new UnityEngine.Texture2D representing the saturation spectrum.
HSVToRGB(float, float, float)
Converts an HSV color to RGB color representation with an alpha of 1.0f.
public static Color HSVToRGB(float hue, float saturation, float value)
Parameters
huefloatThe hue component (0-360 degrees).
saturationfloatThe saturation component (0.0f-1.0f).
valuefloatThe value (brightness) component (0.0f-1.0f).
Returns
- Color
A Unity UnityEngine.Color in RGB format with full alpha.
HSVToRGB(float, float, float, float)
Converts an HSV color to RGB color representation with a specified alpha.
public static Color HSVToRGB(float hue, float saturation, float value, float alpha)
Parameters
huefloatThe hue component (0-360 degrees).
saturationfloatThe saturation component (0.0f-1.0f).
valuefloatThe value (brightness) component (0.0f-1.0f).
alphafloatThe alpha component (0.0f-1.0f).
Returns
- Color
A Unity UnityEngine.Color in RGB format with the specified alpha.
RGBToHSV(float, float, float)
Converts an RGB color to HSV color representation with an alpha of 1.0f.
public static Color RGBToHSV(float red, float green, float blue)
Parameters
redfloatThe red component (0.0f-1.0f).
greenfloatThe green component (0.0f-1.0f).
bluefloatThe blue component (0.0f-1.0f).
Returns
- Color
A Unity UnityEngine.Color where R=Hue (0-360), G=Saturation (0.0-1.0), B=Value (0.0-1.0), A=1.0.
RGBToHSV(float, float, float, float)
Converts an RGB color to HSV color representation with a specified alpha.
public static Color RGBToHSV(float red, float green, float blue, float alpha)
Parameters
redfloatThe red component (0.0f-1.0f).
greenfloatThe green component (0.0f-1.0f).
bluefloatThe blue component (0.0f-1.0f).
alphafloatThe alpha component (0.0f-1.0f).
Returns
- Color
A Unity UnityEngine.Color where R=Hue (0-360), G=Saturation (0.0-1.0), B=Value (0.0-1.0), A=alpha.
Read(Reader)
Reads a TinyColor from a FishNet.Serializing.Reader (FishNet serialization).
public static TinyColor Read(Reader reader)
Parameters
readerReaderThe FishNet Reader to read from.
Returns
ToString()
Returns a string representation of the TinyColor in RGBA format.
public override string ToString()
Returns
- string
A string in the format "RGBA(R, G, B, A)".
ToUnityColor(TinyColor)
Converts a TinyColor to a Unity UnityEngine.Color. Note: This is a duplicate of the extension method. Consider removing one if not both are needed. The extension method ToUnityColor(TinyColor) is generally preferred for consistency.
public static Color ToUnityColor(TinyColor color)
Parameters
colorTinyColorThe TinyColor to convert.
Returns
- Color
A Unity Color representation of the TinyColor.
Write(Writer)
Writes the TinyColor to a FishNet.Serializing.Writer (FishNet serialization).
public void Write(Writer writer)
Parameters
writerWriterThe FishNet Writer to write to.