Hexagon
Loading...
Searching...
No Matches
HexColor Class Reference

Provides extension methods for Unity Color and Vector3 types to simplify common color transformations and formatting. More...

Static Public Member Functions

static Color VectorToColor (this Vector3 vector, float a=1.0f)
 Converts a Vector3 to a Color, using optional alpha.
 
static Color VectorToColor (this Vector4 vector)
 Converts a Vector4 to a Color.
 
static Vector3 ColorToVector3 (this Color color)
 Converts a Color to a Vector3 containing only RGB components.
 
static Vector4 ColorToVector4 (this Color color)
 Converts a Color to a Vector4.
 
static Color WithRed (this Color color, float r)
 Returns a copy of the color with a new red component.
 
static Color WithGreen (this Color color, float g)
 Returns a copy of the color with a new green component.
 
static Color WithBlue (this Color color, float b)
 Returns a copy of the color with a new blue component.
 
static Color WithAlpha (this Color color, float a)
 Returns a copy of the color with a new alpha component.
 
static Color WithBrightness (this Color color, float brightness)
 Applies brightness scaling after normalizing RGB components.
 
static float GetRGBMagnitude (this Color color)
 Computes Euclidean length of RGB components.
 
static float GetRGBAMagnitude (this Color color)
 Computes Euclidean length of RGBA components.
 
static Color ScaleRGB (this Color color, float scalar)
 Scales RGB channels by a given factor.
 
static Color ScaleRGBA (this Color color, float scalar)
 Scales all RGBA channels by a given factor.
 
static Color NormalizeRGB (this Color color)
 Normalizes RGB components to unit length; output brightness is constant.
 
static Color NormalizeRGBA (this Color color)
 Normalizes all RGBA components to unit length; output brightness is constant.
 
static string WrapInHTMLTagRGB (this Color color, string @string)
 Wraps a string in a Unity color tag using RGB only.
 
static string WrapInHTMLTagRGBA (this Color color, string @string)
 Wraps a string in a Unity color tag including alpha.
 

Detailed Description

Provides extension methods for Unity Color and Vector3 types to simplify common color transformations and formatting.

Member Function Documentation

◆ ColorToVector3()

static Vector3 HexColor.ColorToVector3 ( this Color color)
static

Converts a Color to a Vector3 containing only RGB components.

Parameters
colorInput Color.
Returns
Vector3 with r, g, b components.

◆ ColorToVector4()

static Vector4 HexColor.ColorToVector4 ( this Color color)
static

Converts a Color to a Vector4.

Parameters
colorInput Color.
Returns
Vector4 with r, g, b, a components.

◆ GetRGBAMagnitude()

static float HexColor.GetRGBAMagnitude ( this Color color)
inlinestatic

Computes Euclidean length of RGBA components.

Parameters
colorInput color.
Returns
Magnitude of RGBA vector.

◆ GetRGBMagnitude()

static float HexColor.GetRGBMagnitude ( this Color color)
inlinestatic

Computes Euclidean length of RGB components.

Parameters
colorInput color.
Returns
Magnitude of RGB vector.

◆ NormalizeRGB()

static Color HexColor.NormalizeRGB ( this Color color)
inlinestatic

Normalizes RGB components to unit length; output brightness is constant.

Parameters
colorInput color.
Returns
Color with normalized RGB and original alpha.

◆ NormalizeRGBA()

static Color HexColor.NormalizeRGBA ( this Color color)
inlinestatic

Normalizes all RGBA components to unit length; output brightness is constant.

Parameters
colorInput color.
Returns
Color with normalized RGBA.

◆ ScaleRGB()

static Color HexColor.ScaleRGB ( this Color color,
float scalar )
inlinestatic

Scales RGB channels by a given factor.

Parameters
colorInput color.
scalarScaling factor.
Returns
Color with scaled RGB, original alpha.

◆ ScaleRGBA()

static Color HexColor.ScaleRGBA ( this Color color,
float scalar )
inlinestatic

Scales all RGBA channels by a given factor.

Parameters
colorInput color.
scalarScaling factor.
Returns
Color with scaled RGBA components.

◆ VectorToColor() [1/2]

static Color HexColor.VectorToColor ( this Vector3 vector,
float a = 1.0f )
static

Converts a Vector3 to a Color, using optional alpha.

Parameters
vectorVector3 with RGB components in [0,1] range.
aAlpha value to use, default is 1.0.
Returns
A Color constructed from the vector and alpha.

◆ VectorToColor() [2/2]

static Color HexColor.VectorToColor ( this Vector4 vector)
static

Converts a Vector4 to a Color.

Parameters
vectorVector4 with RGBA components in [0,1] range.
Returns
A Color constructed from the vector.

◆ WithAlpha()

static Color HexColor.WithAlpha ( this Color color,
float a )
static

Returns a copy of the color with a new alpha component.

◆ WithBlue()

static Color HexColor.WithBlue ( this Color color,
float b )
static

Returns a copy of the color with a new blue component.

◆ WithBrightness()

static Color HexColor.WithBrightness ( this Color color,
float brightness )
inlinestatic

Applies brightness scaling after normalizing RGB components.

Parameters
colorInput color to adjust.
brightnessScaling factor for brightness.
Returns
Normalized and brightness-scaled color.

◆ WithGreen()

static Color HexColor.WithGreen ( this Color color,
float g )
static

Returns a copy of the color with a new green component.

◆ WithRed()

static Color HexColor.WithRed ( this Color color,
float r )
static

Returns a copy of the color with a new red component.

◆ WrapInHTMLTagRGB()

static string HexColor.WrapInHTMLTagRGB ( this Color color,
string @ string )
inlinestatic

Wraps a string in a Unity color tag using RGB only.

Parameters
colorText color.
stringString to wrap.
Returns
String with Unity color tag applied.

◆ WrapInHTMLTagRGBA()

static string HexColor.WrapInHTMLTagRGBA ( this Color color,
string @ string )
inlinestatic

Wraps a string in a Unity color tag including alpha.

Parameters
colorText color.
stringString to wrap.
Returns
String with Unity color tag applied.

The documentation for this class was generated from the following file: