ReXGlue SDK
Loading...
Searching...
No Matches
rex::ui::Color Struct Reference

#include <rex/ui/style.h>

Public Member Functions

constexpr Color WithAlpha (f32 alpha) const
constexpr Color Scaled (f32 factor) const
constexpr u32 ToRGBA8 () const
constexpr u32 ToARGB8 () const
constexpr bool operator== (const Color &other) const =default

Static Public Member Functions

static constexpr Color FromRGBA (f32 r, f32 g, f32 b, f32 a=1)
static constexpr Color FromRGB8 (u32 rrggbb, f32 a=1)
static constexpr Color FromRGBA8 (u8 r, u8 g, u8 b, u8 a=255)
static constexpr Color FromARGB8 (u32 argb)
static constexpr Color Lerp (Color from, Color to, f32 t)

Public Attributes

f32 r = 0
f32 g = 0
f32 b = 0
f32 a = 1

Detailed Description

A color of four channels in the order red, green, blue, alpha. Each channel runs from 0 to 1.

Member Function Documentation

◆ FromARGB8()

constexpr Color rex::ui::Color::FromARGB8 ( u32 argb)
inlinestaticconstexpr

Returns a color from a packed 0xAARRGGBB value.

Parameters
argbThe packed value, alpha in the high byte.

◆ FromRGB8()

constexpr Color rex::ui::Color::FromRGB8 ( u32 rrggbb,
f32 a = 1 )
inlinestaticconstexpr

Returns a color from a packed 0xRRGGBB value.

Parameters
rrggbbThe packed red, green and blue bytes, red in bits 16 to 23.

◆ FromRGBA()

constexpr Color rex::ui::Color::FromRGBA ( f32 r,
f32 g,
f32 b,
f32 a = 1 )
inlinestaticconstexpr

Returns a color from its channels.

Parameters
aAlpha channel, opaque when omitted.

◆ FromRGBA8()

constexpr Color rex::ui::Color::FromRGBA8 ( u8 r,
u8 g,
u8 b,
u8 a = 255 )
inlinestaticconstexpr

Returns a color from four bytes. Every byte is divided by 255.

Parameters
rRed byte.
gGreen byte.
bBlue byte.
aAlpha byte, 255 is opaque.

◆ Lerp()

constexpr Color rex::ui::Color::Lerp ( Color from,
Color to,
f32 t )
inlinestaticconstexpr

Returns the linear blend of two colors over every channel.

Parameters
fromThe color at t equal to 0.
toThe color at t equal to 1.

◆ Scaled()

Color rex::ui::Color::Scaled ( f32 factor) const
inlineconstexpr

Returns this color with red, green and blue multiplied.

Parameters
factorThe multiplier. Alpha is unchanged.

◆ ToARGB8()

u32 rex::ui::Color::ToARGB8 ( ) const
inlineconstexpr

Returns the packed bytes with alpha in the high byte. The value is a << 24 | r << 16 | g << 8 | b with each channel clamped to 0..1 and rounded.

◆ ToRGBA8()

u32 rex::ui::Color::ToRGBA8 ( ) const
inlineconstexpr

Returns the packed bytes with red in the low byte, the gpu::OverlayVertex order. The value is r | g << 8 | b << 16 | a << 24 with each channel clamped to 0..1 and rounded.

◆ WithAlpha()

Color rex::ui::Color::WithAlpha ( f32 alpha) const
inlineconstexpr

Returns this color with another alpha. The red, green and blue channels stay unchanged.

Member Data Documentation

◆ a

f32 rex::ui::Color::a = 1

1 is opaque.


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