FastLED 3.10.8
Loading...
Searching...
No Matches
raster_sparse.cpp.hpp
Go to the documentation of this file.
1#include "fl/stl/stdint.h"
2
4#include "fl/gfx/leds.h"
6#include "fl/gfx/tile2x2.h"
7#include "fl/stl/noexcept.h"
8
9namespace fl {
10
12 XYDrawComposited visitor(color, xymap, out);
13 draw(xymap, visitor);
14}
15
17 draw(color, leds->xymap(), leds->rgb());
18}
19
22 XYDrawGradient visitor(gradient, xymap, out);
23 draw(xymap, visitor);
24}
25
27 drawGradient(gradient, leds->xymap(), leds->rgb());
28}
29
31 // Tile2x2_u8::Rasterize(tiles, this, mAbsoluteBoundsSet ? &mAbsoluteBounds
32 // : nullptr);
33 if (tiles.size() == 0) {
34 FL_WARN("Rasterize: no tiles");
35 return;
36 }
37 const rect<u16> *optional_bounds =
39
40 // Check if the bounds are set.
41 // draw all now unconditionally.
42 for (const auto &tile : tiles) {
43 // Rasterize the tile.
44 rasterize_internal(tile, optional_bounds);
45 }
46 return;
47}
48
50 const rect<u16> *optional_bounds) FL_NO_EXCEPT {
51 const vec2<u16> &origin = tile.origin();
52 for (int x = 0; x < 2; ++x) {
53 for (int y = 0; y < 2; ++y) {
54 u8 value = tile.at(x, y);
55 if (!value) {
56 continue;
57 }
58 int xx = origin.x + x;
59 int yy = origin.y + y;
60 if (optional_bounds && !optional_bounds->contains(xx, yy)) {
61 continue;
62 }
63 write(vec2<u16>(xx, yy), value);
64 }
65 }
66}
67
68} // namespace fl
69
70// XYRasterSparse_RGB8 implementation
72 for (const auto &it : mSparseGrid) {
73 auto pt = it.first;
74 if (!xymap.has(pt.x, pt.y)) {
75 continue;
76 }
77 u32 index = xymap(pt.x, pt.y);
78 const CRGB &color = it.second;
79 // Only draw non-black pixels (since black represents "no data")
80 if (color.r != 0 || color.g != 0 || color.b != 0) {
81 out[index] = color;
82 }
83 }
84}
85
CRGB leds[1]
XYMap xymap
void draw(const XYMap &xymap, fl::span< CRGB > out) FL_NO_EXCEPT
void rasterize_internal(const Tile2x2_u8 &tile, const rect< u16 > *optional_bounds=nullptr) FL_NO_EXCEPT
fl::rect< u16 > mAbsoluteBounds
void write(const vec2< u16 > &pt, u8 value) FL_NO_EXCEPT
void draw(const CRGB &color, const XYMap &xymap, fl::span< CRGB > out) FL_NO_EXCEPT
void rasterize(const vec2< u16 > &pt, u8 value) FL_NO_EXCEPT
void drawGradient(const Gradient &gradient, const XYMap &xymap, fl::span< CRGB > out) FL_NO_EXCEPT
void draw(float pos)
Definition curr.h:526
#define FL_WARN(...)
Definition log.h:437
unsigned char u8
Definition stdint.h:131
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
constexpr int type_rank< T >::value
Base definition for an LED controller.
Definition crgb.hpp:179
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38
value_type y
Definition geometry.h:191
value_type x
Definition geometry.h:190