FastLED 3.9.15
Loading...
Searching...
No Matches
raster_sparse.cpp
Go to the documentation of this file.
1
2
3#include <stdint.h>
4
5#include "fl/draw_visitor.h"
6#include "fl/raster_sparse.h"
7#include "fl/tile2x2.h"
8
9namespace fl {
10
11void XYRasterU8Sparse::draw(const CRGB &color, const XYMap &xymap, CRGB *out) {
12 XYDrawComposited visitor(color, xymap, out);
13 draw(xymap, visitor);
14}
15
17 const XYMap &xymap, CRGB *out) {
18 XYDrawGradient visitor(gradient, xymap, out);
19 draw(xymap, visitor);
20}
21
23 // Tile2x2_u8::Rasterize(tiles, this, mAbsoluteBoundsSet ? &mAbsoluteBounds
24 // : nullptr);
25 if (tiles.size() == 0) {
26 FASTLED_WARN("Rasterize: no tiles");
27 return;
28 }
29 const rect<int> *optional_bounds =
31
32 // Check if the bounds are set.
33 // draw all now unconditionally.
34 for (const auto &tile : tiles) {
35 // Rasterize the tile.
36 rasterize_internal(tile, optional_bounds);
37 }
38 return;
39}
40
42 const rect<int> *optional_bounds) {
43 const vec2<int> &origin = tile.origin();
44 for (int x = 0; x < 2; ++x) {
45 for (int y = 0; y < 2; ++y) {
46 uint8_t value = tile.at(x, y);
47 if (!value) {
48 continue;
49 }
50 int xx = origin.x + x;
51 int yy = origin.y + y;
52 if (optional_bounds && !optional_bounds->contains(xx, yy)) {
53 continue;
54 }
55 write(vec2<int>(xx, yy), value);
56 }
57 }
58}
59
60} // namespace fl
XYMap xymap(WIDTH, HEIGHT, SERPENTINE)
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:82
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:83
size_t size() const
Definition slice.h:90
vec2< int > origin() const
Definition tile2x2.h:62
uint8_t & at(int x, int y)
Definition tile2x2.h:35
void write(const vec2< int > &pt, uint8_t value)
fl::rect< int > mAbsoluteBounds
void rasterize_internal(const Tile2x2_u8 &tile, const rect< int > *optional_bounds=nullptr)
void draw(const CRGB &color, const XYMap &xymap, CRGB *out)
void drawGradient(const Gradient &gradient, const XYMap &xymap, CRGB *out)
void rasterize(const vec2< int > &pt, uint8_t value)
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:55
bool contains(const vec2< T > &p) const
Definition geometry.h:256
#define FASTLED_WARN
Definition warn.h:7