47 constexpr color(
color const&)
noexcept =
default;
49 constexpr color& operator=(
color const&)
noexcept =
default;
50 constexpr color& operator=(
color&&)
noexcept =
default;
52 [[nodiscard]]
constexpr explicit color(f16x4
const&
other) noexcept : _v(
other)
54 hi_axiom(holds_invariant());
57 [[nodiscard]]
constexpr explicit color(f32x4
const&
other) noexcept :
color(
static_cast<f16x4
>(
other)) {}
59 [[nodiscard]]
constexpr explicit operator f16x4()
const noexcept
64 [[nodiscard]]
constexpr explicit operator f32x4()
const noexcept
66 return static_cast<f32x4
>(_v);
69 [[nodiscard]]
constexpr color(
float r,
float g,
float b,
float a = 1.0f) noexcept :
color(f32x4{r, g, b, a}) {}
71 [[nodiscard]]
constexpr color() noexcept :
color(f32x4{}) {}
75 _v.x() = float16::from_uint16_t(0xf900 +
static_cast<uint8_t
>(
semantic_color));
76 _v.y() = float16::from_uint16_t(0x0000);
77 _v.z() = float16::from_uint16_t(0x0000);
78 _v.w() = float16(1.0f);
81 [[nodiscard]]
constexpr bool is_semantic()
const noexcept
83 return (_v.x().get() & 0xf900) == 0xf900;
88 hi_axiom(is_semantic());
93 [[nodiscard]]
constexpr static color blue()
noexcept {
return color{semantic_color::blue}; }
94 [[nodiscard]]
constexpr static color green()
noexcept {
return color{semantic_color::green}; }
95 [[nodiscard]]
constexpr static color indigo()
noexcept {
return color{semantic_color::indigo}; }
96 [[nodiscard]]
constexpr static color orange()
noexcept {
return color{semantic_color::orange}; }
97 [[nodiscard]]
constexpr static color pink()
noexcept {
return color{semantic_color::pink}; }
98 [[nodiscard]]
constexpr static color purple()
noexcept {
return color{semantic_color::purple}; }
99 [[nodiscard]]
constexpr static color red()
noexcept {
return color{semantic_color::red}; }
100 [[nodiscard]]
constexpr static color teal()
noexcept {
return color{semantic_color::teal}; }
101 [[nodiscard]]
constexpr static color yellow()
noexcept {
return color{semantic_color::yellow}; }
102 [[nodiscard]]
constexpr static color gray()
noexcept {
return color{semantic_color::gray}; }
103 [[nodiscard]]
constexpr static color gray2()
noexcept {
return color{semantic_color::gray2}; }
104 [[nodiscard]]
constexpr static color gray3()
noexcept {
return color{semantic_color::gray3}; }
105 [[nodiscard]]
constexpr static color gray4()
noexcept {
return color{semantic_color::gray4}; }
106 [[nodiscard]]
constexpr static color gray5()
noexcept {
return color{semantic_color::gray5}; }
107 [[nodiscard]]
constexpr static color gray6()
noexcept {
return color{semantic_color::gray6}; }
108 [[nodiscard]]
constexpr static color foreground()
noexcept {
return color{semantic_color::foreground}; }
109 [[nodiscard]]
constexpr static color border()
noexcept {
return color{semantic_color::border}; }
110 [[nodiscard]]
constexpr static color fill()
noexcept {
return color{semantic_color::fill}; }
111 [[nodiscard]]
constexpr static color accent()
noexcept {
return color{semantic_color::accent}; }
112 [[nodiscard]]
constexpr static color text_select()
noexcept {
return color{semantic_color::text_select}; }
113 [[nodiscard]]
constexpr static color primary_cursor()
noexcept {
return color{semantic_color::primary_cursor}; }
114 [[nodiscard]]
constexpr static color secondary_cursor()
noexcept {
return color{semantic_color::secondary_cursor}; }
117 [[nodiscard]]
constexpr static color transparent()
noexcept
119 return {0.0f, 0.0f, 0.0f, 0.0f};
122 [[nodiscard]]
constexpr static color white()
noexcept
124 return {1.0f, 1.0f, 1.0f, 1.0f};
127 [[nodiscard]]
constexpr static color black()
noexcept
129 return {0.0f, 0.0f, 0.0f, 1.0f};
132 [[nodiscard]]
size_t hash()
const noexcept
137 [[nodiscard]]
constexpr float16& r()
noexcept
142 [[nodiscard]]
constexpr float16& g()
noexcept
147 [[nodiscard]]
constexpr float16& b()
noexcept
152 [[nodiscard]]
constexpr float16& a()
noexcept
157 [[nodiscard]]
constexpr float16 r()
const noexcept
162 [[nodiscard]]
constexpr float16 g()
const noexcept
167 [[nodiscard]]
constexpr float16 b()
const noexcept
172 [[nodiscard]]
constexpr float16 a()
const noexcept
177 [[nodiscard]]
constexpr bool holds_invariant()
const noexcept
179 return _v.w() >= 0.0 && _v.w() <= 1.0;
182 [[nodiscard]]
constexpr friend bool operator==(
color const& lhs,
color const& rhs)
noexcept
184 return equal(lhs._v, rhs._v);
187 [[nodiscard]]
constexpr friend color operator*(
color const& lhs,
color const& rhs)
noexcept
189 return color{lhs._v * rhs._v};
197 [[nodiscard]]
constexpr friend color desaturate(
color const& rhs)
noexcept
199 hilet rhs_ = f32x4{rhs};
201 hilet Y = 0.2126f * rhs_.r() + 0.7152f * rhs_.g() + 0.0722f * rhs_.b();
203 return color{Y, Y, Y, rhs_.a()};
215 [[nodiscard]]
constexpr friend color
operator*(
matrix3 const& lhs, color
const& rhs)
noexcept
217 hi_axiom(rhs.holds_invariant());
219 get<0>(lhs) *
static_cast<f32x4
>(rhs).xxxx() + get<1>(lhs) *
static_cast<f32x4
>(rhs).yyyy() +
220 get<2>(lhs) *
static_cast<f32x4
>(rhs).zzzz() + get<3>(lhs)};
hi_export void composit(pixmap_span< sfloat_rgba16 > dst, hi::color color, graphic_path const &mask) noexcept
Composit color onto the destination image where the mask is solid.
Definition graphic_path.hpp:667
constexpr void fill(pixmap_span< uint8_t > image, std::vector< bezier_curve > const &curves) noexcept
Fill a linear gray scale image by filling a curve with anti-aliasing.
Definition bezier_curve.hpp:667