11 inv_period_(1.0f / (gradient_.back().value - gradient_.
front().value)) {
12 for (
const Node&
n : gradient_) {
31 if (value < gradient_.front().value) {
32 float diff = gradient_.front().value - value;
33 if (
diff >= 1)
return color::Transparent;
34 return gradient_.front().color.withA(255 *
diff);
36 if (value > gradient_.back().value) {
37 float diff = value - gradient_.back().value;
38 if (
diff >= 1)
return color::Transparent;
39 return gradient_.back().color.withA(255 *
diff);
44 if (value < gradient_.front().value || value > gradient_.back().value) {
45 float adj = value - gradient_.front().value;
46 float period = gradient_.back().value - gradient_.front().value;
60 return gradient_[0].color;
62 return gradient_.back().color;
109 while (count-- > 0) {
112 float r =
sqrtf(dx * dx + dy * dy);
129 while (count-- > 0) {
153 while (count-- > 0) {
157 while (count-- > 0) {
161 }
else if (dy_ == 0.0f) {
163 while (count-- > 0) {
167 while (count-- > 0) {
172 while (count-- > 0) {
173 *
result++ = gradient_.
getColor((*x++ - cx_) * dx_ + (*y++ - cy_) * dy_);
180 int16_t width = xMax - xMin + 1;
183 for (
int16_t y = yMin; y <= yMax; ++y) {
188 for (
int16_t y = yMin; y <= yMax; ++y) {
193 }
else if (dy_ == 0.0f) {
196 for (
int16_t x = xMin; x <= xMax; ++x) {
199 for (
int16_t y = yMin + 1; y <= yMax; ++y) {
205 for (
int16_t x = xMin; x <= xMax; ++x) {
208 for (
int16_t y = yMin + 1; y <= yMax; ++y) {
214 for (
int16_t y = yMin; y <= yMax; ++y) {
215 for (
int16_t x = xMin; x <= xMax; ++x) {
216 *
result++ = gradient_.
getColor((x - cx_) * dx_ + (y - cy_) * dy_);
232 while (count-- > 0) {
240 os <<
"ColorGradient::Boundary::kExtended";
243 os <<
"ColorGradient::Boundary::kTruncated";
246 os <<
"ColorGradient::Boundary::kPeriodic";
249 os <<
"ColorGradient::Boundary::(unknown)";
void readColors(const int16_t *x, const int16_t *y, uint32_t count, Color *result) const override
Read colors for the given points.
AngularGradient(FpPoint center, ColorGradient gradient, Box extents=Box::MaximumBox())
Create an angular gradient.
Axis-aligned integer rectangle.
Multi-point gradient specification.
Color getColor(float value) const
Return the color for a given value.
Boundary
Boundary behavior outside gradient range.
ColorGradient(std::vector< Node > gradient, Boundary boundary=Boundary::kExtended)
Create a gradient specification.
ARGB8888 color stored as a 32-bit unsigned integer.
void readColors(const int16_t *x, const int16_t *y, uint32_t count, Color *result) const override
Read colors for the given points.
LinearGradient(Point origin, float dx, float dy, ColorGradient gradient, Box extents=Box::MaximumBox())
Create a linear gradient.
bool readColorRect(int16_t xMin, int16_t yMin, int16_t xMax, int16_t yMax, Color *result) const override
Read colors for a rectangle.
RadialGradientSq(Point center, ColorGradient gradient, Box extents=Box::MaximumBox())
Create a radial gradient using squared distance.
void readColors(const int16_t *x, const int16_t *y, uint32_t count, Color *result) const override
Read colors for the given points.
void readColors(const int16_t *x, const int16_t *y, uint32_t count, Color *result) const override
Read colors for the given points.
RadialGradient(FpPoint center, ColorGradient gradient, Box extents=Box::MaximumBox())
Create a radial gradient.
Defines 140 opaque HTML named colors.
TransparencyMode
Transparency information for a stream or color mode.
@ kNone
All colors are fully opaque.
@ kCrude
Colors are either fully opaque or fully transparent.
@ kFull
Colors may include partial transparency (alpha channel).
roo_logging::Stream & operator<<(roo_logging::Stream &os, BlendingMode mode)
void FillColor(Color *buf, uint32_t count, Color color)
Fill an array with a single color.
Color InterpolateColors(Color c1, Color c2, int16_t fraction)
Interpolate between two colors with fraction in [0, 256].
A single node in the gradient.