Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::utils::Color Class Referencefinal

Public Member Functions

 Color (const GdkRGBA &color) noexcept
 Color (const QColor &color) noexcept
 Color (float r, float g, float b, float a=1.0f) noexcept
 Color (const std::string &str)
 Construct a new Color object by parsing the color string.
Coloroperator= (const GdkRGBA &color)
Coloroperator= (const QColor &color)
Colorbrighten (float val)
 Brightens the color by the given amount.
Colorbrighten_default ()
 Brightens the color by the default amount.
Colordarken (float val)
 Darkens the color by the given amount.
Colordarken_default ()
 Darkens the color by the default amount.
bool is_same (const Color &other) const
 Returns whether the color is the same as another.
bool is_bright () const
 Returns if the color is bright or not.
bool is_very_bright () const
 Returns if the color is very bright or not.
bool is_very_very_bright () const
 Returns if the color is very very bright or not.
bool is_very_dark () const
 Returns if the color is very dark or not.
bool is_very_very_dark () const
 Returns if the color is very very dark or not.
Color get_opposite () const
 Gets the opposite color.
float get_brightness () const
 Gets the brightness of the color.
float get_darkness () const
 Gets the darkness of the color.
Color morph (const Color &other, float amt) const
 Morphs from this color to another, depending on the given amount.
Color get_contrast_color () const
 Returns the contrasting color (variation of black or white) based on if the given color is dark enough or not.
GdkRGBA to_gdk_rgba () const
GdkRGBA to_gdk_rgba_with_alpha (float alpha) const
QColor to_qcolor () const
std::string to_hex () const
 Converts the color to a hex string.

Static Public Member Functions

static Color get_mid_color (const Color &c1, const Color &c2, const float transition=0.5f)
 Returns the color in-between two colors.
static Color get_arranger_object_color (const Color &color, bool is_hovered, bool is_selected, bool is_transient, bool is_muted)
 Gets the color the widget should be.
static std::string rgb_to_hex (float r, float g, float b)

Data Fields

float red_ = 0.f
 Red.
float green_ = 0.f
 Green.
float blue_ = 0.f
 Blue.
float alpha_ = 1.0f
 Alpha.

Static Public Attributes

static constexpr auto DEFAULT_BRIGHTEN_VAL = 0.1f

Friends

bool operator== (const Color &lhs, const Color &rhs)

Detailed Description

Definition at line 23 of file color.h.

Constructor & Destructor Documentation

◆ Color() [1/3]

zrythm::utils::Color::Color ( const GdkRGBA & color)
inlinenoexcept

Definition at line 29 of file color.h.

◆ Color() [2/3]

zrythm::utils::Color::Color ( const QColor & color)
inlinenoexcept

Definition at line 30 of file color.h.

◆ Color() [3/3]

zrythm::utils::Color::Color ( const std::string & str)

Construct a new Color object by parsing the color string.

Parameters
str

Member Function Documentation

◆ get_arranger_object_color()

Color zrythm::utils::Color::get_arranger_object_color ( const Color & color,
bool is_hovered,
bool is_selected,
bool is_transient,
bool is_muted )
static

Gets the color the widget should be.

Parameters
colorThe original color.
is_selectedWhether the widget is supposed to be selected or not.

◆ get_mid_color()

Color zrythm::utils::Color::get_mid_color ( const Color & c1,
const Color & c2,
const float transition = 0.5f )
static

Returns the color in-between two colors.

Parameters
transitionHow far to transition (0.5 for half).

◆ morph()

Color zrythm::utils::Color::morph ( const Color & other,
float amt ) const
nodiscard

Morphs from this color to another, depending on the given amount.

Eg, if amt is 0, the resulting color will be this color. If amt is 1, the resulting color will be other.

◆ to_hex()

std::string zrythm::utils::Color::to_hex ( ) const

Converts the color to a hex string.

Returns
std::string

Field Documentation

◆ alpha_

float zrythm::utils::Color::alpha_ = 1.0f

Alpha.

Definition at line 166 of file color.h.

◆ blue_

float zrythm::utils::Color::blue_ = 0.f

Blue.

Definition at line 165 of file color.h.

◆ DEFAULT_BRIGHTEN_VAL

auto zrythm::utils::Color::DEFAULT_BRIGHTEN_VAL = 0.1f
staticconstexpr

Definition at line 26 of file color.h.

◆ green_

float zrythm::utils::Color::green_ = 0.f

Green.

Definition at line 164 of file color.h.

◆ red_

float zrythm::utils::Color::red_ = 0.f

Red.

Definition at line 163 of file color.h.


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