| 65 | } |
| 66 | |
| 67 | void Frame::drawXY(fl::span<CRGB> leds, const XYMap &xyMap, DrawMode draw_mode) const { |
| 68 | const u16 width = xyMap.getWidth(); |
| 69 | const u16 height = xyMap.getHeight(); |
| 70 | fl::u32 count = 0; |
| 71 | for (u16 h = 0; h < height; ++h) { |
| 72 | for (u16 w = 0; w < width; ++w) { |
| 73 | fl::u32 in_idx = xyMap(w, h); |
| 74 | fl::u32 out_idx = count++; |
| 75 | if (in_idx >= mPixelsCount) { |
| 76 | FL_WARN( |
| 77 | "Frame::drawXY: in index out of range: " << in_idx); |
| 78 | continue; |
| 79 | } |
| 80 | if (out_idx >= mPixelsCount) { |
| 81 | FL_WARN( |
| 82 | "Frame::drawXY: out index out of range: " << out_idx); |
| 83 | continue; |
| 84 | } |
| 85 | switch (draw_mode) { |
| 86 | case DrawMode::DRAW_MODE_BLEND: // gfx primitives only; treat as overwrite for Frame |
| 87 | case DrawMode::DRAW_MODE_OVERWRITE: { |
| 88 | leds[out_idx] = mRgb[in_idx]; |
| 89 | break; |
| 90 | } |
| 91 | case DrawMode::DRAW_MODE_BLEND_BY_MAX_BRIGHTNESS: { |
| 92 | leds[out_idx] = |
| 93 | CRGB::blendAlphaMaxChannel(mRgb[in_idx], leds[in_idx]); |
| 94 | break; |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | void Frame::clear() { |
| 102 | if (mPixelsCount > 0 && !mRgb.empty()) { |