| 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 | }; |
nothing calls this directly
no test coverage detected