UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FColor Struct Reference

#include <Color.h>

Public Member Functions

uint32DWColor (void)
 
const uint32DWColor (void) const
 
 FColor ()=default
 
UE_FORCEINLINE_HINT FColor (EForceInit)
 
constexpr FColor (uint8 InR, uint8 InG, uint8 InB, uint8 InA=255)
 
UE_FORCEINLINE_HINT FColor (uint32 InColor)
 
bool Serialize (FArchive &Ar)
 
bool Serialize (FStructuredArchive::FSlot Slot)
 
UE_FORCEINLINE_HINT bool operator== (const FColor &C) const
 
UE_FORCEINLINE_HINT bool operator!= (const FColor &C) const
 
void operator+= (const FColor &C)
 
CORE_API FLinearColor FromRGBE () const
 
FColor WithAlpha (uint8 Alpha) const
 
FLinearColor ReinterpretAsLinear () const
 
CORE_API FString ToHex () const
 
CORE_API FString ToString () const
 
CORE_API bool InitFromString (const FString &InSourceString)
 
UE_FORCEINLINE_HINT uint32 ToPackedARGB () const
 
UE_FORCEINLINE_HINT uint32 ToPackedABGR () const
 
UE_FORCEINLINE_HINT uint32 ToPackedRGBA () const
 
UE_FORCEINLINE_HINT uint32 ToPackedBGRA () const
 

Static Public Member Functions

static CORE_API FColor FromHex (const FString &HexString)
 
static CORE_API FColor MakeRandomColor ()
 
static CORE_API FColor MakeRedToGreenColorFromScalar (float Scalar)
 
static CORE_API FColor MakeFromColorTemperature (float Temp)
 
static CORE_API FColor MakeRandomSeededColor (int32 Seed)
 
static uint8 QuantizeUNormFloatTo8 (float UnitFloat)
 
static uint16 QuantizeUNormFloatTo16 (float UnitFloat)
 
static float DequantizeUNorm8ToFloat (int Value8)
 
static float DequantizeUNorm16ToFloat (int Value16)
 
static uint8 Requantize10to8 (int Value10)
 
static uint8 Requantize16to8 (int Value16)
 
static FColor MakeRequantizeFrom1010102 (int R, int G, int B, int A)
 

Public Attributes

union { 
 
   struct { 
 
      uint8   A 
 
      uint8   R 
 
      uint8   G 
 
      uint8   B 
 
   }  
 
   uint32   Bits 
 
};  
 

Static Public Attributes

static CORE_API const FColor White
 
static CORE_API const FColor Black
 
static CORE_API const FColor Transparent
 
static CORE_API const FColor Red
 
static CORE_API const FColor Green
 
static CORE_API const FColor Blue
 
static CORE_API const FColor Yellow
 
static CORE_API const FColor Cyan
 
static CORE_API const FColor Magenta
 
static CORE_API const FColor Orange
 
static CORE_API const FColor Purple
 
static CORE_API const FColor Turquoise
 
static CORE_API const FColor Silver
 
static CORE_API const FColor Emerald
 

Friends

FArchiveoperator<< (FArchive &Ar, FColor &Color)
 
void operator<< (FStructuredArchive::FSlot Slot, FColor &Color)
 
UE_FORCEINLINE_HINT uint32 GetTypeHash (const FColor &Color)
 

Constructor & Destructor Documentation

◆ FColor() [1/4]

FColor::FColor ( )
default

◆ FColor() [2/4]

UE_FORCEINLINE_HINT FColor::FColor ( EForceInit  )
inlineexplicit

◆ FColor() [3/4]

constexpr FColor::FColor ( uint8  InR,
uint8  InG,
uint8  InB,
uint8  InA = 255 
)
inlineconstexpr

◆ FColor() [4/4]

UE_FORCEINLINE_HINT FColor::FColor ( uint32  InColor)
inlineexplicit

Member Function Documentation

◆ DequantizeUNorm16ToFloat()

static float FColor::DequantizeUNorm16ToFloat ( int  Value16)
inlinestatic

◆ DequantizeUNorm8ToFloat()

static float FColor::DequantizeUNorm8ToFloat ( int  Value8)
inlinestatic

◆ DWColor() [1/2]

uint32 & FColor::DWColor ( void  )
inline

◆ DWColor() [2/2]

const uint32 & FColor::DWColor ( void  ) const
inline

◆ FromHex()

FColor FColor::FromHex ( const FString &  HexString)
static

Creates a color value from the given hexadecimal string.

Supported formats are: RGB, RRGGBB, RRGGBBAA, RGB, RRGGBB, RRGGBBAA

Parameters
HexString- The hexadecimal string.
Returns
The corresponding color value.
See also
ToHex

◆ FromRGBE()

FLinearColor FColor::FromRGBE ( ) const

Converts from RGBE to a linear float color as outlined in Gregory Ward's Real Pixels article, Graphics Gems II, page 80. Implementation details in https://cbloomrants.blogspot.com/2020/06/widespread-error-in-radiance-hdr-rgbe.html

◆ InitFromString()

bool FColor::InitFromString ( const FString &  InSourceString)

Initialize this Color based on an FString. The String is expected to contain R=, G=, B=, A=. The FColor will be bogus when InitFromString returns false.

Parameters
InSourceStringFString containing the color values.
Returns
true if the R,G,B values were read successfully; false otherwise.

◆ MakeFromColorTemperature()

FColor FColor::MakeFromColorTemperature ( float  Temp)
static

Converts temperature in Kelvins of a black body radiator to RGB chromaticity.

◆ MakeRandomColor()

FColor FColor::MakeRandomColor ( )
static

Makes a random but quite nice color.

◆ MakeRandomSeededColor()

FColor FColor::MakeRandomSeededColor ( int32  Seed)
static

Makes a random color based on a seed.

◆ MakeRedToGreenColorFromScalar()

FColor FColor::MakeRedToGreenColorFromScalar ( float  Scalar)
static

Makes a color red->green with the passed in scalar (e.g. 0 is red, 1 is green)

◆ MakeRequantizeFrom1010102()

static FColor FColor::MakeRequantizeFrom1010102 ( int  R,
int  G,
int  B,
int  A 
)
inlinestatic

Return 8-bit color Quantized from 10-bit RGB , 2-bit A

◆ operator!=()

UE_FORCEINLINE_HINT bool FColor::operator!= ( const FColor C) const
inline

◆ operator+=()

void FColor::operator+= ( const FColor C)
inline

◆ operator==()

UE_FORCEINLINE_HINT bool FColor::operator== ( const FColor C) const
inline

◆ QuantizeUNormFloatTo16()

static uint16 FColor::QuantizeUNormFloatTo16 ( float  UnitFloat)
inlinestatic

◆ QuantizeUNormFloatTo8()

static uint8 FColor::QuantizeUNormFloatTo8 ( float  UnitFloat)
inlinestatic

Conversions to/from GPU UNorm floats, U8, U16 matches convention of FColor FLinearColor::QuantizeRound

◆ ReinterpretAsLinear()

FLinearColor FColor::ReinterpretAsLinear ( ) const
inline

Reinterprets the color as a linear color. This is the correct dequantizer for QuantizeRound. This matches the GPU spec conversion for U8<->float

Returns
The linear color representation.

◆ Requantize10to8()

static uint8 FColor::Requantize10to8 ( int  Value10)
inlinestatic

◆ Requantize16to8()

static uint8 FColor::Requantize16to8 ( int  Value16)
inlinestatic

◆ Serialize() [1/2]

bool FColor::Serialize ( FArchive Ar)
inline

◆ Serialize() [2/2]

bool FColor::Serialize ( FStructuredArchive::FSlot  Slot)
inline

◆ ToHex()

FString FColor::ToHex ( ) const

Converts this color value to a hexadecimal string.

The format of the string is RRGGBBAA.

Returns
Hexadecimal string.
See also
FromHex, ToString

◆ ToPackedABGR()

UE_FORCEINLINE_HINT uint32 FColor::ToPackedABGR ( ) const
inline

Gets the color in a packed uint32 format packed in the order ABGR.

◆ ToPackedARGB()

UE_FORCEINLINE_HINT uint32 FColor::ToPackedARGB ( ) const
inline

Gets the color in a packed uint32 format packed in the order ARGB.

◆ ToPackedBGRA()

UE_FORCEINLINE_HINT uint32 FColor::ToPackedBGRA ( ) const
inline

Gets the color in a packed uint32 format packed in the order BGRA.

◆ ToPackedRGBA()

UE_FORCEINLINE_HINT uint32 FColor::ToPackedRGBA ( ) const
inline

Gets the color in a packed uint32 format packed in the order RGBA.

◆ ToString()

FString FColor::ToString ( ) const

Converts this color value to a string.

Returns
The string representation.
See also
ToHex

◆ WithAlpha()

FColor FColor::WithAlpha ( uint8  Alpha) const
inline
Returns
a new FColor based of this color with the new alpha value. Usage: const FColor& MyColor = FColorList::Green.WithAlpha(128);

Friends And Related Symbol Documentation

◆ GetTypeHash

UE_FORCEINLINE_HINT uint32 GetTypeHash ( const FColor Color)
friend

◆ operator<< [1/2]

FArchive & operator<< ( FArchive Ar,
FColor Color 
)
friend

◆ operator<< [2/2]

void operator<< ( FStructuredArchive::FSlot  Slot,
FColor Color 
)
friend

Member Data Documentation

◆ [union]

union { ... } FColor

◆ A

uint8 FColor::A

◆ B

uint8 FColor::B

◆ Bits

uint32 FColor::Bits

◆ Black

const FColor FColor::Black
static

◆ Blue

const FColor FColor::Blue
static

◆ Cyan

const FColor FColor::Cyan
static

◆ Emerald

const FColor FColor::Emerald
static

◆ G

uint8 FColor::G

◆ Green

const FColor FColor::Green
static

◆ Magenta

const FColor FColor::Magenta
static

◆ Orange

const FColor FColor::Orange
static

◆ Purple

const FColor FColor::Purple
static

◆ R

uint8 FColor::R

◆ Red

const FColor FColor::Red
static

◆ Silver

const FColor FColor::Silver
static

◆ Transparent

const FColor FColor::Transparent
static

◆ Turquoise

const FColor FColor::Turquoise
static

◆ White

const FColor FColor::White
static

Some pre-inited colors, useful for debug code

◆ Yellow

const FColor FColor::Yellow
static

The documentation for this struct was generated from the following files: