7#include "../color/color.hpp"
8#include "../float16.hpp"
9#include "../pixel_map.hpp"
10#include "../geometry/corner_radii.hpp"
11#include "../rapid/numeric_array.hpp"
17namespace hi::inline
v1 {
31 constexpr sfloat_rgba16(
f16x4 const &rhs) noexcept : v(std::bit_cast<
decltype(v)>(rhs)) {}
35 v = std::bit_cast<decltype(v)>(rhs);
39 constexpr explicit operator f16x4()
const noexcept
41 return std::bit_cast<f16x4>(v);
48 return *
this =
static_cast<f16x4>(rhs);
55 return *
this =
static_cast<f16x4>(rhs);
58 constexpr explicit operator color()
const noexcept
67 return hash_mix(v[0], v[1], v[2], v[3]);
76 std::get<3>(r.v) = 0x0000;
91inline void composit(pixel_map<sfloat_rgba16> &under, pixel_map<sfloat_rgba16>
const &over)
noexcept
93 hi_assert(over.height() >= under.height());
94 hi_assert(over.width() >= under.width());
96 for (
std::size_t rowNr = 0; rowNr != under.height(); ++rowNr) {
97 hilet overRow = over.at(rowNr);
98 auto underRow = under.at(rowNr);
99 for (
std::size_t columnNr = 0; columnNr != under.width(); ++columnNr) {
100 hilet &overPixel = overRow[columnNr];
101 auto &underPixel = underRow[columnNr];
103 underPixel =
composit(
static_cast<f16x4
>(underPixel),
static_cast<f16x4
>(overPixel));
108inline void composit(pixel_map<sfloat_rgba16> &under, color over, pixel_map<uint8_t>
const &mask)
noexcept
110 hi_assert(mask.height() >= under.height());
111 hi_assert(mask.width() >= under.width());
113 auto maskPixel = color{1.0f, 1.0f, 1.0f, 1.0f};
115 for (
std::size_t rowNr = 0; rowNr != under.height(); ++rowNr) {
116 hilet maskRow = mask.at(rowNr);
117 auto underRow = under.at(rowNr);
118 for (
std::size_t columnNr = 0; columnNr != under.width(); ++columnNr) {
119 hilet maskValue = maskRow[columnNr] / 255.0f;
120 maskPixel.a() = maskValue;
122 auto &pixel = underRow[columnNr];
123 pixel =
composit(
static_cast<color
>(pixel), over * maskPixel);
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:15
void composit(pixel_map< sfloat_rgba16 > &dst, hi::color color, graphic_path const &mask) noexcept
Composit color onto the destination image where the mask is solid.
The HikoGUI namespace.
Definition ascii.hpp:19
This is a RGBA floating point color.
Definition color.hpp:39
Definition corner_radii.hpp:9
A 2D canvas of pixels.
Definition pixel_map.hpp:111
Definition sfloat_rgba16.hpp:19