Skip to main content
Version: 15.x (API 15) [Current]

Class ColorHelpers

Class containing various methods for manipulating colors.

Assembly: Dalamud.dll​
Declaration
public static class ColorHelpers

Methods​

RgbaVector4ToUint(Vector4)​

Pack a vector4 color into a uint for use in ImGui APIs.

Declaration
public static uint RgbaVector4ToUint(Vector4 color)
Returns​

System.UInt32: The packed color.

Parameters​
TypeNameDescription
System.Numerics.Vector4colorThe color to pack.

RgbaUintToVector4(uint)​

Convert a RGBA color in the range of 0.f to 1.f to a uint.

Declaration
public static Vector4 RgbaUintToVector4(uint color)
Returns​

System.Numerics.Vector4: The packed color.

Parameters​
TypeNameDescription
System.UInt32colorThe color to pack.

RgbaToHsv(Vector4)​

Convert a RGBA color in the range of 0.f to 1.f to a HSV color.

Declaration
public static ColorHelpers.HsvaColor RgbaToHsv(Vector4 color)
Returns​

Dalamud.Interface.ColorHelpers.HsvaColor: The color in a HSV representation.

Parameters​
TypeNameDescription
System.Numerics.Vector4colorThe color to convert.

HsvToRgb(HsvaColor)​

Convert a HSV color to a RGBA color in the range of 0.f to 1.f.

Declaration
public static Vector4 HsvToRgb(ColorHelpers.HsvaColor hsv)
Returns​

System.Numerics.Vector4: The RGB color.

Parameters​
TypeNameDescription
Dalamud.Interface.ColorHelpers.HsvaColorhsvThe color to convert.

SwapEndianness(uint)​

Performs a swap of endianness Exmaple: (FFXIV) RGBA to ABGR (ImGui).

Declaration
public static uint SwapEndianness(uint rgba)
Returns​

System.UInt32: Endian swapped color value with new byte order W Z Y X.

Parameters​
TypeNameDescription
System.UInt32rgbaColor value in byte order X Y Z W.

Lighten(Vector4, float)​

Lighten a color.

Declaration
public static Vector4 Lighten(this Vector4 color, float amount)
Returns​

System.Numerics.Vector4: The lightened color.

Parameters​
TypeNameDescription
System.Numerics.Vector4colorThe color to lighten.
System.SingleamountThe amount to lighten.

Lighten(uint, float)​

Lighten a color.

Declaration
public static uint Lighten(uint color, float amount)
Returns​

System.UInt32: The lightened color.

Parameters​
TypeNameDescription
System.UInt32colorThe color to lighten.
System.SingleamountThe amount to lighten.

Darken(Vector4, float)​

Darken a color.

Declaration
public static Vector4 Darken(this Vector4 color, float amount)
Returns​

System.Numerics.Vector4: The darkened color.

Parameters​
TypeNameDescription
System.Numerics.Vector4colorThe color to lighten.
System.SingleamountThe amount to lighten.

Darken(uint, float)​

Darken a color.

Declaration
public static uint Darken(uint color, float amount)
Returns​

System.UInt32: The darkened color.

Parameters​
TypeNameDescription
System.UInt32colorThe color to lighten.
System.SingleamountThe amount to lighten.

Saturate(Vector4, float)​

Saturate a color.

Declaration
public static Vector4 Saturate(this Vector4 color, float amount)
Returns​

System.Numerics.Vector4: The saturated color.

Parameters​
TypeNameDescription
System.Numerics.Vector4colorThe color to lighten.
System.SingleamountThe amount to lighten.

Saturate(uint, float)​

Saturate a color.

Declaration
public static uint Saturate(uint color, float amount)
Returns​

System.UInt32: The saturated color.

Parameters​
TypeNameDescription
System.UInt32colorThe color to lighten.
System.SingleamountThe amount to lighten.

Desaturate(Vector4, float)​

Desaturate a color.

Declaration
public static Vector4 Desaturate(this Vector4 color, float amount)
Returns​

System.Numerics.Vector4: The desaturated color.

Parameters​
TypeNameDescription
System.Numerics.Vector4colorThe color to lighten.
System.SingleamountThe amount to lighten.

Desaturate(uint, float)​

Desaturate a color.

Declaration
public static uint Desaturate(uint color, float amount)
Returns​

System.UInt32: The desaturated color.

Parameters​
TypeNameDescription
System.UInt32colorThe color to lighten.
System.SingleamountThe amount to lighten.

ApplyOpacity(uint, float)​

Applies the given opacity value ranging from 0 to 1 to an uint value containing a RGBA value.

Declaration
public static uint ApplyOpacity(uint rgba, float opacity)
Returns​

System.UInt32: Transformed value.

Parameters​
TypeNameDescription
System.UInt32rgbaRGBA value to transform.
System.SingleopacityOpacity to apply.

SwapRedBlue(uint)​

Swaps red and blue channels of a given color in ARGB(BB GG RR AA) and ABGR(RR GG BB AA).

Declaration
public static uint SwapRedBlue(uint x)
Returns​

System.UInt32: Swapped color.

Parameters​
TypeNameDescription
System.UInt32xColor to process.

Fade(Vector4, float)​

Fade a color.

Declaration
public static Vector4 Fade(this Vector4 color, float amount)
Returns​

System.Numerics.Vector4: The faded color.

Parameters​
TypeNameDescription
System.Numerics.Vector4colorThe color to lighten.
System.SingleamountThe amount to lighten.

WithAlpha(Vector4, float)​

Set alpha of a color.

Declaration
public static Vector4 WithAlpha(this Vector4 color, float alpha)
Returns​

System.Numerics.Vector4: The color with the set alpha value.

Parameters​
TypeNameDescription
System.Numerics.Vector4colorThe color.
System.SinglealphaThe alpha value to set.

Fade(uint, float)​

Fade a color.

Declaration
public static uint Fade(uint color, float amount)
Returns​

System.UInt32: The faded color.

Parameters​
TypeNameDescription
System.UInt32colorThe color to lighten.
System.SingleamountThe amount to lighten.

Vector(KnownColor)​

Convert a KnownColor to a RGBA vector with values between 0.0f and 1.0f.

Declaration
public static Vector4 Vector(this KnownColor knownColor)
Returns​

System.Numerics.Vector4: RGBA Vector with values between 0.0f and 1.0f.

Parameters​
TypeNameDescription
System.Drawing.KnownColorknownColorKnown Color to convert.

NormalizeToUnitRange(Vector4)​

Normalizes a Vector4 with RGBA 255 color values to values between 0.0f and 1.0f If values are out of RGBA 255 range, the original value is returned.

Declaration
public static Vector4 NormalizeToUnitRange(this Vector4 color)
Returns​

System.Numerics.Vector4: A vector with values between 0.0f and 1.0f.

Parameters​
TypeNameDescription
System.Numerics.Vector4colorThe color vector to convert.