8#include <boost/describe.hpp>
9#include <nlohmann/json_fwd.hpp>
17 static constexpr auto DEFAULT_BRIGHTEN_VAL = 0.1f;
19 Color ()
noexcept =
default;
20 Color (
const QColor &color)
noexcept { *
this = color; }
21 Color (
float r,
float g,
float b,
float a = 1.0f)
noexcept;
30 Color &operator= (
const QColor &color);
55 [[nodiscard]]
bool is_same (
const Color &other)
const;
104 [[nodiscard]] Color
morph (
const Color &other,
float amt)
const;
112 get_mid_color (
const Color &c1,
const Color &c2,
const float transition = 0.5f);
120 QColor to_qcolor ()
const;
163 friend bool operator== (
const Color &lhs,
const Color &rhs);
165 friend void to_json (nlohmann::json &j,
const Color &color);
166 friend void from_json (
const nlohmann::json &j, Color &color);
float get_brightness() const
Gets the brightness of the color.
Color & darken_default()
Darkens the color by the default amount.
static Color get_mid_color(const Color &c1, const Color &c2, const float transition=0.5f)
Returns the color in-between two colors.
bool is_bright() const
Returns if the color is bright or not.
float get_darkness() const
Gets the darkness of the color.
Color get_contrast_color() const
Returns the contrasting color (variation of black or white) based on if the given color is dark enoug...
Color & darken(float val)
Darkens the color by the given amount.
bool is_very_bright() const
Returns if the color is very bright or not.
Color get_opposite() const
Gets the opposite color.
static Color from_hex(std::string_view hex)
Parses a hex color string using QColor.
Color & brighten(float val)
Brightens the color by the given amount.
Color morph(const Color &other, float amt) const
Morphs from this color to another, depending on the given amount.
static std::string rgb_to_hex(float r, float g, float b)
Converts RGB float values to a hex string.
Color(std::string_view hex)
Construct a new Color object by parsing a hex color string.
bool is_same(const Color &other) const
Returns whether the color is the same as another.
std::string to_hex() const
Converts the color to a hex string (RGB only).
bool is_very_very_dark() const
Returns if the color is very very dark or not.
Color & brighten_default()
Brightens the color by the default amount.
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.
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.