NovaSVG 0.10.0
A header-only SVG library
Loading...
Searching...
No Matches
novasvg::ColorBlend Class Reference

Lightweight helper class for color blending operations. More...

#include <color.h>

Collaboration diagram for novasvg::ColorBlend:

Public Member Functions

 ColorBlend (const Color &base, int percent)
 Construct a ColorBlend from a base color and percentage.
 
Color operator| (const Color &other) const
 Finalize the blend with a specific color.
 
ColorBlend operator| (const ColorBlend &other) const
 Chain multiple blend operations.
 
 operator Color () const
 Implicit conversion to Color.
 

Public Attributes

Color baseColor
 The base color being blended.
 
int percentage
 Percentage for the blend operation (0-100)
 

Detailed Description

Lightweight helper class for color blending operations.

This class holds the intermediate state of a color blend operation and allows chaining multiple blends in a fluent manner.

Note
This class is primarily used internally by the blend operators. It supports implicit conversion to Color when the blend is finalized.
Usage
// Single blend with transparent (default)
ColorBlend b1 = "gray"_c | 50;
Color c1 = b1; // 50% gray + 50% transparent
// Chain with another color
Color c2 = "gray"_c | 50 | "black"_c;
Represents a color in RGBA format (0xRRGGBBAA).
Definition color.h:85
Lightweight helper class for color blending operations.
Definition color.h:856

Definition at line 856 of file color.h.

Constructor & Destructor Documentation

◆ ColorBlend()

novasvg::ColorBlend::ColorBlend ( const Color &  base,
int  percent 
)
inline

Construct a ColorBlend from a base color and percentage.

Parameters
baseThe base color to blend.
percentThe percentage of the blend (0-100).

Definition at line 866 of file color.h.

Member Function Documentation

◆ operator Color()

novasvg::ColorBlend::operator Color ( ) const
inline

Implicit conversion to Color.

Finalizes the blend with transparent (default behavior).

Returns
The final blended color.

Definition at line 909 of file color.h.

References baseColor, novasvg::Color::blend(), percentage, and novasvg::Color::transparent().

◆ operator|() [1/2]

Color novasvg::ColorBlend::operator| ( const Color &  other) const
inline

Finalize the blend with a specific color.

Blends the base color with the specified color using the stored percentage.

Parameters
otherThe color to blend with.
Returns
The final blended Color.
Example
Color c = ("gray"_c | 50) | "black"_c;

Definition at line 883 of file color.h.

References baseColor, novasvg::Color::blend(), and percentage.

◆ operator|() [2/2]

ColorBlend novasvg::ColorBlend::operator| ( const ColorBlend &  other) const
inline

Chain multiple blend operations.

Allows chaining like: "gray"_c | 50 | "black"_c

Parameters
otherThe ColorBlend to chain with.
Returns
A new ColorBlend representing the chained operation.

Definition at line 895 of file color.h.

References baseColor, novasvg::Color::blend(), percentage, and novasvg::Color::transparent().

Member Data Documentation

◆ baseColor

Color novasvg::ColorBlend::baseColor

The base color being blended.

Definition at line 857 of file color.h.

Referenced by operator Color(), operator|(), and operator|().

◆ percentage

int novasvg::ColorBlend::percentage

Percentage for the blend operation (0-100)

Definition at line 858 of file color.h.

Referenced by operator Color(), operator|(), and operator|().


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