MCPcopy Create free account
hub / github.com/FastLED/FastLED / draw

Method draw

src/fl/fx/2d/redsquare.h:19–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17 RedSquare(const XYMap& xymap) : Fx2d(xymap) {}
18
19 void draw(DrawContext context) override {
20 u16 width = getWidth();
21 u16 height = getHeight();
22 u16 square_size = Math::Min(width, height) / 2;
23 u16 start_x = (width - square_size) / 2;
24 u16 start_y = (height - square_size) / 2;
25
26 for (u16 x = 0; x < width; x++) {
27 for (u16 y = 0; y < height; y++) {
28 u16 idx = mXyMap.mapToIndex(x, y);
29 if (idx < mXyMap.getTotal()) {
30 if (x >= start_x && x < start_x + square_size &&
31 y >= start_y && y < start_y + square_size) {
32 context.leds[idx] = CRGB::Red;
33 } else {
34 context.leds[idx] = CRGB::Black;
35 }
36 }
37 }
38 }
39 }
40
41 fl::string fxName() const override { return "red_square"; }
42};

Callers

nothing calls this directly

Calls 2

getTotalMethod · 0.80
mapToIndexMethod · 0.45

Tested by

no test coverage detected