Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::canvas::Color Struct Reference

#include <canvas.hpp>

Classes

struct  HSV
struct  HSL
struct  OKLCH

Public Member Functions

HSV to_hsv () const
 Convert to HSV (h in [0,360), s and v in [0,1]).
HSL to_hsl () const
 Convert to HSL (h in [0,360), s and l in [0,1]).
OKLCH to_oklch () const
 Convert to OKLCH (perceptually uniform, CSS Color Level 4) L in [0,1], C in [0,~0.4], h in [0,360).
void encode (uint8_t *out) const
 Serialize to compact binary (4x float LE, 16 bytes).
Color interpolate (const Color &other, float t) const
 Interpolate between this color and other by factor t [0,1].
Color with_hdr_intensity (float multiplier) const
 Scale color intensity for HDR (channels can exceed 1.0).
Color with_alpha (float alpha) const
 Return copy with different alpha.
uint8_t r8 () const
 Convert to 8-bit values for serialization/interop.
uint8_t g8 () const
uint8_t b8 () const
uint8_t a8 () const
uint32_t to_argb32 () const
 Pack to uint32_t ARGB (clamped to [0,255]) for Skia/platform interop.
bool operator== (const Color &other) const
bool operator!= (const Color &other) const

Static Public Member Functions

static constexpr Color rgba (float r, float g, float b, float a=1.0f)
 Construct from float channels [0,1] (>1.0 allowed for HDR).
static constexpr Color rgba8 (uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
 Construct from 8-bit channels [0,255] — convenience for legacy/hex code.
static Color hex (uint32_t rgb)
 Construct from hex 0xRRGGBB (alpha = 1.0).
static Color from_hsv (HSV hsv, float alpha=1.0f)
static Color from_hsl (HSL hsl, float alpha=1.0f)
static Color from_oklch (OKLCH oklch, float alpha=1.0f)
static Color decode (const uint8_t *data)
static Color from_argb32 (uint32_t argb)
 Unpack from uint32_t ARGB.

Public Attributes

float r = 0.0f
float g = 0.0f
float b = 0.0f
float a = 1.0f

Member Function Documentation

◆ a8()

uint8_t pulp::canvas::Color::a8 ( ) const
inline

◆ b8()

uint8_t pulp::canvas::Color::b8 ( ) const
inline

◆ decode()

Color pulp::canvas::Color::decode ( const uint8_t * data)
static

◆ encode()

void pulp::canvas::Color::encode ( uint8_t * out) const

Serialize to compact binary (4x float LE, 16 bytes).

◆ from_argb32()

Color pulp::canvas::Color::from_argb32 ( uint32_t argb)
inlinestatic

Unpack from uint32_t ARGB.

◆ from_hsl()

Color pulp::canvas::Color::from_hsl ( HSL hsl,
float alpha = 1.0f )
static

◆ from_hsv()

Color pulp::canvas::Color::from_hsv ( HSV hsv,
float alpha = 1.0f )
static

◆ from_oklch()

Color pulp::canvas::Color::from_oklch ( OKLCH oklch,
float alpha = 1.0f )
static

◆ g8()

uint8_t pulp::canvas::Color::g8 ( ) const
inline

◆ hex()

Color pulp::canvas::Color::hex ( uint32_t rgb)
inlinestatic

Construct from hex 0xRRGGBB (alpha = 1.0).

◆ interpolate()

Color pulp::canvas::Color::interpolate ( const Color & other,
float t ) const
inline

Interpolate between this color and other by factor t [0,1].

◆ operator!=()

bool pulp::canvas::Color::operator!= ( const Color & other) const
inline

◆ operator==()

bool pulp::canvas::Color::operator== ( const Color & other) const
inline

◆ r8()

uint8_t pulp::canvas::Color::r8 ( ) const
inline

Convert to 8-bit values for serialization/interop.

◆ rgba()

constexpr Color pulp::canvas::Color::rgba ( float r,
float g,
float b,
float a = 1.0f )
inlinestaticconstexpr

Construct from float channels [0,1] (>1.0 allowed for HDR).

◆ rgba8()

constexpr Color pulp::canvas::Color::rgba8 ( uint8_t r,
uint8_t g,
uint8_t b,
uint8_t a = 255 )
inlinestaticconstexpr

Construct from 8-bit channels [0,255] — convenience for legacy/hex code.

◆ to_argb32()

uint32_t pulp::canvas::Color::to_argb32 ( ) const
inline

Pack to uint32_t ARGB (clamped to [0,255]) for Skia/platform interop.

◆ to_hsl()

HSL pulp::canvas::Color::to_hsl ( ) const

Convert to HSL (h in [0,360), s and l in [0,1]).

◆ to_hsv()

HSV pulp::canvas::Color::to_hsv ( ) const

Convert to HSV (h in [0,360), s and v in [0,1]).

◆ to_oklch()

OKLCH pulp::canvas::Color::to_oklch ( ) const

Convert to OKLCH (perceptually uniform, CSS Color Level 4) L in [0,1], C in [0,~0.4], h in [0,360).

◆ with_alpha()

Color pulp::canvas::Color::with_alpha ( float alpha) const
inline

Return copy with different alpha.

◆ with_hdr_intensity()

Color pulp::canvas::Color::with_hdr_intensity ( float multiplier) const
inline

Scale color intensity for HDR (channels can exceed 1.0).

Member Data Documentation

◆ a

float pulp::canvas::Color::a = 1.0f

◆ b

float pulp::canvas::Color::b = 0.0f

◆ g

float pulp::canvas::Color::g = 0.0f

◆ r

float pulp::canvas::Color::r = 0.0f

The documentation for this struct was generated from the following file:
  • /home/runner/work/pulp/pulp/core/canvas/include/pulp/canvas/canvas.hpp