NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
Color

Provides functions for color conversion and manipulation. More...

Functions

u8 nnl::utl::color::Convert4To8 (u8 v) noexcept
 Converts a 4-bit color channel value to an 8-bit color channel value.
u8 nnl::utl::color::Convert5To8 (u8 v) noexcept
 Converts a 5-bit color channel value to an 8-bit color channel value.
u8 nnl::utl::color::Convert6To8 (u8 v) noexcept
 Converts a 6-bit color channel value to an 8-bit color channel value.
u32 nnl::utl::color::RGBA4444ToRGBA8888 (u16 src) noexcept
 Converts RGBA4444 color format to RGBA8888 color format.
u32 nnl::utl::color::RGBA5551ToRGBA8888 (u16 src) noexcept
 Converts RGBA5551 color format to RGBA8888 color format.
u32 nnl::utl::color::RGB565ToRGBA8888 (u16 src) noexcept
 Converts RGB565 color format to RGBA8888 color format.
u16 nnl::utl::color::RGBA8888ToRGB565 (u32 value) noexcept
 Converts RGBA8888 color format to RGB565 color format.
u16 nnl::utl::color::RGBA8888ToRGBA5551 (u32 value) noexcept
 Converts RGBA8888 color format to RGBA5551 color format.
u16 nnl::utl::color::RGBA8888ToRGBA4444 (u32 value) noexcept
 Converts RGBA8888 color format to RGBA4444 color format.
std::string nnl::utl::color::IntToHex (u32 color, bool alpha=true)
 Converts an integer color value to a hex string representation.
u32 nnl::utl::color::HexToInt (std::string hex)
 Converts a hex string representation of a color to an integer color value.
glm::vec4 nnl::utl::color::IntToFloat (u32 color) noexcept
 Converts an integer color value to a floating-point vector representation.
u8 nnl::utl::color::FloatToInt (float color) noexcept
 Converts a floating-point color value to an integer color representation.
u32 nnl::utl::color::FloatToInt (glm::vec3 color) noexcept
 Converts a vec3 floating-point color vector to an integer color representation.
u32 nnl::utl::color::FloatToInt (glm::vec4 color)
 Converts a vec4 floating-point color vector to an integer color representation.
float nnl::utl::color::SRGBToLinear (float c) noexcept
 Converts an sRGB color value to a linear color value.
template<typename T>
nnl::utl::color::SRGBToLinear (T color)
 Converts a vec of sRGB color values to linear color values.
float nnl::utl::color::LinearToSRGB (float c) noexcept
 Converts a linear color value to an sRGB color value.
template<typename T>
nnl::utl::color::LinearToSRGB (T color)
 Converts a vector of linear color values to sRGB color values.

Detailed Description

Provides functions for color conversion and manipulation.

Function Documentation

◆ Convert4To8()

u8 nnl::utl::color::Convert4To8 ( u8 v)
inlinenoexcept

Converts a 4-bit color channel value to an 8-bit color channel value.

Parameters
vThe 4-bit color channel value.
Returns
The converted 8-bit color channel value.

◆ Convert5To8()

u8 nnl::utl::color::Convert5To8 ( u8 v)
inlinenoexcept

Converts a 5-bit color channel value to an 8-bit color channel value.

Parameters
vThe 5-bit color channel value.
Returns
The converted 8-bit color channel value.

◆ Convert6To8()

u8 nnl::utl::color::Convert6To8 ( u8 v)
inlinenoexcept

Converts a 6-bit color channel value to an 8-bit color channel value.

Parameters
vThe 6-bit color channel value.
Returns
The converted 8-bit color channel value.

◆ FloatToInt() [1/3]

u8 nnl::utl::color::FloatToInt ( float color)
inlinenoexcept

Converts a floating-point color value to an integer color representation.

Parameters
colorThe floating-point value representing a color component (0.0 to 1.0).
Returns
A 32-bit integer representing the color.

◆ FloatToInt() [2/3]

u32 nnl::utl::color::FloatToInt ( glm::vec3 color)
inlinenoexcept

Converts a vec3 floating-point color vector to an integer color representation.

Parameters
colorThe vec3 color vector where components are in the range [0.0, 1.0].
Returns
A 32-bit integer representing the color in RGBA format.

◆ FloatToInt() [3/3]

u32 nnl::utl::color::FloatToInt ( glm::vec4 color)
inline

Converts a vec4 floating-point color vector to an integer color representation.

Parameters
colorThe vec4 color vector where components are in the range [0.0, 1.0].
Returns
A 32-bit integer representing the color in RGBA format.

◆ HexToInt()

u32 nnl::utl::color::HexToInt ( std::string hex)
inline

Converts a hex string representation of a color to an integer color value.

Parameters
hexThe hex string representing the color (format: "#RRGGBBAA").
Returns
A 32-bit integer representing the color in RGBA format.

◆ IntToFloat()

glm::vec4 nnl::utl::color::IntToFloat ( u32 color)
inlinenoexcept

Converts an integer color value to a floating-point vector representation.

Parameters
colorThe 32-bit integer representing RGBA color.
Returns
A vec4 representing the color in normalized floating-point values.

◆ IntToHex()

std::string nnl::utl::color::IntToHex ( u32 color,
bool alpha = true )
inline

Converts an integer color value to a hex string representation.

Parameters
colorThe 32-bit integer representing RGBA color.
alphaBoolean flag to include alpha in hex representation.
Returns
A hex string representing the color (format: "#RRGGBBAA").

◆ LinearToSRGB() [1/2]

float nnl::utl::color::LinearToSRGB ( float c)
inlinenoexcept

Converts a linear color value to an sRGB color value.

Parameters
cThe linear color component.
Returns
The corresponding sRGB color component.

◆ LinearToSRGB() [2/2]

template<typename T>
T nnl::utl::color::LinearToSRGB ( T color)

Converts a vector of linear color values to sRGB color values.

Template Parameters
TType of the color container (e.g., glm::vec3).
Parameters
colorThe color container with linear components.
Returns
The color container with sRGB components.

◆ RGB565ToRGBA8888()

u32 nnl::utl::color::RGB565ToRGBA8888 ( u16 src)
inlinenoexcept

Converts RGB565 color format to RGBA8888 color format.

Parameters
srcThe source color in RGB565 format.
Returns
The converted color in RGBA8888 format.

◆ RGBA4444ToRGBA8888()

u32 nnl::utl::color::RGBA4444ToRGBA8888 ( u16 src)
inlinenoexcept

Converts RGBA4444 color format to RGBA8888 color format.

Parameters
srcThe source color in RGBA4444 format.
Returns
The converted color in RGBA8888 format.

◆ RGBA5551ToRGBA8888()

u32 nnl::utl::color::RGBA5551ToRGBA8888 ( u16 src)
inlinenoexcept

Converts RGBA5551 color format to RGBA8888 color format.

Parameters
srcThe source color in RGBA5551 format.
Returns
The converted color in RGBA8888 format.

◆ RGBA8888ToRGB565()

u16 nnl::utl::color::RGBA8888ToRGB565 ( u32 value)
inlinenoexcept

Converts RGBA8888 color format to RGB565 color format.

Parameters
valueThe source color in RGBA8888 format.
Returns
The converted color in RGB565 format.

◆ RGBA8888ToRGBA4444()

u16 nnl::utl::color::RGBA8888ToRGBA4444 ( u32 value)
inlinenoexcept

Converts RGBA8888 color format to RGBA4444 color format.

Parameters
valueThe source color in RGBA8888 format.
Returns
The converted color in RGBA4444 format.

◆ RGBA8888ToRGBA5551()

u16 nnl::utl::color::RGBA8888ToRGBA5551 ( u32 value)
inlinenoexcept

Converts RGBA8888 color format to RGBA5551 color format.

Parameters
valueThe source color in RGBA8888 format.
Returns
The converted color in RGBA5551 format.

◆ SRGBToLinear() [1/2]

float nnl::utl::color::SRGBToLinear ( float c)
inlinenoexcept

Converts an sRGB color value to a linear color value.

Parameters
cThe sRGB color component.
Returns
The corresponding linear color component.

◆ SRGBToLinear() [2/2]

template<typename T>
T nnl::utl::color::SRGBToLinear ( T color)

Converts a vec of sRGB color values to linear color values.

Template Parameters
TType of the color container (e.g., glm::vec3).
Parameters
colorThe color container with sRGB components.
Returns
The color vector with linear components.