Table of Contents

Class TinyColor

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

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

red byte

The red component (0-255).

green byte

The green component (0-255).

blue byte

The 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

red byte

The red component (0-255).

green byte

The green component (0-255).

blue byte

The blue component (0-255).

alpha byte

The alpha (transparency) component (0-255).

Fields

a

The Alpha (transparency) component of the color (0-255).

public readonly byte a

Field Value

byte

b

The Blue component of the color (0-255).

public readonly byte b

Field Value

byte

black

The black predefined color constant.

public static readonly TinyColor black

Field Value

TinyColor

bloodRed

The bloodRed predefined color constant.

public static readonly TinyColor bloodRed

Field Value

TinyColor

blue

The blue predefined color constant.

public static readonly TinyColor blue

Field Value

TinyColor

bronze

The bronze predefined color constant.

public static readonly TinyColor bronze

Field Value

TinyColor

charcoal

The charcoal predefined color constant.

public static readonly TinyColor charcoal

Field Value

TinyColor

chartreuse

The chartreuse predefined color constant.

public static readonly TinyColor chartreuse

Field Value

TinyColor

chocolate

The chocolate predefined color constant.

public static readonly TinyColor chocolate

Field Value

TinyColor

coral

The coral predefined color constant.

public static readonly TinyColor coral

Field Value

TinyColor

crimson

The crimson predefined color constant.

public static readonly TinyColor crimson

Field Value

TinyColor

cyan

The cyan predefined color constant.

public static readonly TinyColor cyan

Field Value

TinyColor

darkGrey

The darkGrey predefined color constant.

public static readonly TinyColor darkGrey

Field Value

TinyColor

darkSlateGreen

The darkSlateGreen predefined color constant.

public static readonly TinyColor darkSlateGreen

Field Value

TinyColor

dimGrey

The dimGrey predefined color constant.

public static readonly TinyColor dimGrey

Field Value

TinyColor

forestGreen

The forestGreen predefined color constant.

public static readonly TinyColor forestGreen

Field Value

TinyColor

g

The Green component of the color (0-255).

public readonly byte g

Field Value

byte

gainsboro

The gainsboro predefined color constant.

public static readonly TinyColor gainsboro

Field Value

TinyColor

gold

The gold predefined color constant.

public static readonly TinyColor gold

Field Value

TinyColor

goldenrod

The goldenrod predefined color constant.

public static readonly TinyColor goldenrod

Field Value

TinyColor

green

The green predefined color constant.

public static readonly TinyColor green

Field Value

TinyColor

hotPink

The hotPink predefined color constant.

public static readonly TinyColor hotPink

Field Value

TinyColor

indigo

The indigo predefined color constant.

public static readonly TinyColor indigo

Field Value

TinyColor

lavender

The lavender predefined color constant.

public static readonly TinyColor lavender

Field Value

TinyColor

lightGrey

The lightGrey predefined color constant.

public static readonly TinyColor lightGrey

Field Value

TinyColor

limeGreen

The limeGreen predefined color constant.

public static readonly TinyColor limeGreen

Field Value

TinyColor

magenta

The magenta predefined color constant.

public static readonly TinyColor magenta

Field Value

TinyColor

maroon

The maroon predefined color constant.

public static readonly TinyColor maroon

Field Value

TinyColor

midnightBlue

The midnightBlue predefined color constant.

public static readonly TinyColor midnightBlue

Field Value

TinyColor

navy

The navy predefined color constant.

public static readonly TinyColor navy

Field Value

TinyColor

offWhite

The offWhite predefined color constant.

public static readonly TinyColor offWhite

Field Value

TinyColor

olive

The olive predefined color constant.

public static readonly TinyColor olive

Field Value

TinyColor

orange

The orange predefined color constant.

public static readonly TinyColor orange

Field Value

TinyColor

orchid

The orchid predefined color constant.

public static readonly TinyColor orchid

Field Value

TinyColor

plum

The plum predefined color constant.

public static readonly TinyColor plum

Field Value

TinyColor

r

The Red component of the color (0-255).

public readonly byte r

Field Value

byte

red

The red predefined color constant.

public static readonly TinyColor red

Field Value

TinyColor

royalBlue

The royalBlue predefined color constant.

public static readonly TinyColor royalBlue

Field Value

TinyColor

saddleBrown

The saddleBrown predefined color constant.

public static readonly TinyColor saddleBrown

Field Value

TinyColor

seaGreen

The seaGreen predefined color constant.

public static readonly TinyColor seaGreen

Field Value

TinyColor

sienna

The sienna predefined color constant.

public static readonly TinyColor sienna

Field Value

TinyColor

silver

The silver predefined color constant.

public static readonly TinyColor silver

Field Value

TinyColor

skyBlue

The skyBlue predefined color constant.

public static readonly TinyColor skyBlue

Field Value

TinyColor

slateGrey

The slateGrey predefined color constant.

public static readonly TinyColor slateGrey

Field Value

TinyColor

steelBlue

The steelBlue predefined color constant.

public static readonly TinyColor steelBlue

Field Value

TinyColor

teal

The teal predefined color constant.

public static readonly TinyColor teal

Field Value

TinyColor

transparent

The transparent predefined color constant.

public static readonly TinyColor transparent

Field Value

TinyColor

turquoise

The turquoise predefined color constant.

public static readonly TinyColor turquoise

Field Value

TinyColor

violet

The violet predefined color constant.

public static readonly TinyColor violet

Field Value

TinyColor

wheat

The wheat predefined color constant.

public static readonly TinyColor wheat

Field Value

TinyColor

white

The white predefined color constant.

public static readonly TinyColor white

Field Value

TinyColor

yellow

The yellow predefined color constant.

public static readonly TinyColor yellow

Field Value

TinyColor

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

colorString string

The string to parse (e.g., "RGBA(128, 64, 255, 100)").

Returns

TinyColor

A new TinyColor object if parsing is successful, otherwise indigo.

FromUnityColor(Color)

Creates a TinyColor from a Unity UnityEngine.Color.

public static TinyColor FromUnityColor(Color color)

Parameters

color Color

The 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

width int

The width of the generated texture.

height int

The height of the generated texture.

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

red float

The red component value (0.0f-1.0f).

green float

The green component value (0.0f-1.0f).

width int

The width of the generated texture.

height int

The 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

red float

The red component value (0.0f-1.0f).

green float

The green component value (0.0f-1.0f).

alpha float

The alpha value for the generated colors (0.0f-1.0f).

width int

The width of the generated texture.

height int

The 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

width int

The width of the generated texture.

height int

The height of the generated texture.

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

width int

The width of the generated texture.

height int

The height of the generated texture.

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

alpha float

The alpha value for the generated colors (0.0f-1.0f).

width int

The width of the generated texture.

height int

The 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

red float

The red component value (0.0f-1.0f).

blue float

The blue component value (0.0f-1.0f).

width int

The width of the generated texture.

height int

The 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

red float

The red component value (0.0f-1.0f).

blue float

The blue component value (0.0f-1.0f).

alpha float

The alpha value for the generated colors (0.0f-1.0f).

width int

The width of the generated texture.

height int

The 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

hue float

The hue value for the texture (0-360 degrees).

width int

The width of the generated texture (represents value).

height int

The 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

hue float

The hue value for the texture (0-360 degrees).

alpha float

The alpha value for the generated colors (0.0f-1.0f).

width int

The width of the generated texture (represents value).

height int

The 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

green float

The green component value (0.0f-1.0f).

blue float

The blue component value (0.0f-1.0f).

width int

The width of the generated texture.

height int

The 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

green float

The green component value (0.0f-1.0f).

blue float

The blue component value (0.0f-1.0f).

alpha float

The alpha value for the generated colors (0.0f-1.0f).

width int

The width of the generated texture.

height int

The 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

hue float

The hue value for the spectrum (0-360 degrees).

value float

The value (brightness) for the spectrum (0.0f-1.0f).

width int

The width of the generated texture.

height int

The 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

hue float

The hue value for the spectrum (0-360 degrees).

value float

The value (brightness) for the spectrum (0.0f-1.0f).

alpha float

The alpha value for the generated colors (0.0f-1.0f).

width int

The width of the generated texture.

height int

The 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

hue float

The hue component (0-360 degrees).

saturation float

The saturation component (0.0f-1.0f).

value float

The 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

hue float

The hue component (0-360 degrees).

saturation float

The saturation component (0.0f-1.0f).

value float

The value (brightness) component (0.0f-1.0f).

alpha float

The 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

red float

The red component (0.0f-1.0f).

green float

The green component (0.0f-1.0f).

blue float

The 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

red float

The red component (0.0f-1.0f).

green float

The green component (0.0f-1.0f).

blue float

The blue component (0.0f-1.0f).

alpha float

The 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

reader Reader

The FishNet Reader to read from.

Returns

TinyColor

A new TinyColor object deserialized from the reader.

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

color TinyColor

The 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

writer Writer

The FishNet Writer to write to.