11FASTLED_NAMESPACE_BEGIN
14Frame::Frame(
int pixels_count,
bool has_alpha)
15 : mPixelsCount(pixels_count), mRgb() {
16 mRgb.reset(
reinterpret_cast<CRGB *
>(LargeBlockAllocate(pixels_count *
sizeof(
CRGB))));
17 memset(mRgb.get(), 0, pixels_count *
sizeof(
CRGB));
19 mAlpha.reset(
reinterpret_cast<uint8_t *
>(LargeBlockAllocate(pixels_count)));
20 memset(mAlpha.get(), 0, pixels_count);
26 LargeBlockDeallocate(mRgb.release());
29 LargeBlockDeallocate(mAlpha.release());
33void Frame::draw(
CRGB* leds, uint8_t* alpha)
const {
35 memcpy(leds, mRgb.get(), mPixelsCount *
sizeof(
CRGB));
37 if (alpha && mAlpha) {
38 memcpy(alpha, mAlpha.get(), mPixelsCount);
42void Frame::interpolate(
const Frame& frame1,
const Frame& frame2, uint8_t amountofFrame2,
CRGB* pixels, uint8_t* alpha) {
44 if (frame1.size() != frame2.size()) {
48 const CRGB* rgbFirst = frame1.rgb();
49 const CRGB* rgbSecond = frame2.rgb();
51 if (!rgbFirst || !rgbSecond) {
56 for (
size_t i = 0; i < frame2.size(); ++i) {
57 pixels[i] = CRGB::blend(rgbFirst[i], rgbSecond[i], amountofFrame2);
62void Frame::interpolate(
const Frame& frame1,
const Frame& frame2, uint8_t progress) {
63 if (frame1.size() != frame2.size() || frame1.size() != mPixelsCount) {
66 interpolate(frame1, frame2, progress, mRgb.get(), mAlpha.get());
Representation of an RGB pixel (Red, Green, Blue)