18#define FASTLED_SCALE_UP_ALWAYS_POWER_OF_2 0
21#define FASTLED_SCALE_UP_HIGH_PRECISION 1
26#define FASTLED_SCALE_UP_DECIDE_AT_RUNTIME 2
28#define FASTLED_SCALE_UP_FORCE_FLOATING_POINT 3
30#ifndef FASTLED_SCALE_UP
31#define FASTLED_SCALE_UP FASTLED_SCALE_UP_DECIDE_AT_RUNTIME
36ScaleUp::ScaleUp(XYMap xymap, Fx2dPtr fx) : Fx2d(xymap), mDelegate(fx) {
40 mDelegate->getXYMap().setRectangularGrid();
45 mSurface.reset(
new CRGB[mDelegate->getNumLeds()]);
48 delegateContext.leds = mSurface.get();
49 mDelegate->draw(delegateContext);
51 uint16_t in_w = mDelegate->getWidth();
52 uint16_t in_h = mDelegate->getHeight();
53 uint16_t out_w = getWidth();
54 uint16_t out_h = getHeight();
56 if (in_w == out_w && in_h == out_h) {
57 noExpand(mSurface.get(), context.leds, in_w, in_h);
59 expand(mSurface.get(), context.leds, in_w, in_h, mXyMap);
63void ScaleUp::expand(
const CRGB *input,
CRGB *output, uint16_t width,
64 uint16_t height,
XYMap mXyMap) {
65#if FASTLED_SCALE_UP == FASTLED_SCALE_UP_ALWAYS_POWER_OF_2
67#elif FASTLED_SCALE_UP == FASTLED_SCALE_UP_HIGH_PRECISION
69#elif FASTLED_SCALE_UP == FASTLED_SCALE_UP_DECIDE_AT_RUNTIME
70 bilinearExpand(input, output, width, height, mXyMap);
71#elif FASTLED_SCALE_UP == FASTLED_SCALE_UP_FORCE_FLOATING_POINT
72 bilinearExpandFloat(input, output, width, height, mXyMap);
74#error "Invalid FASTLED_SCALE_UP"
78void ScaleUp::noExpand(
const CRGB *input,
CRGB *output, uint16_t width,
80 uint16_t n = mXyMap.getTotal();
81 for (uint16_t w = 0; w < width; w++) {
82 for (uint16_t h = 0; h < height; h++) {
83 uint16_t idx = mXyMap.mapToIndex(w, h);
85 output[idx] = input[w * height + h];
central include file for FastLED, defines the CFastLED class/object
Demonstrates how to mix noise generation with color palettes on a 2D LED matrix.
Implements a simple red square effect for 2D LED grids.
void bilinearExpandArbitrary(const CRGB *input, CRGB *output, uint16_t inputWidth, uint16_t inputHeight, XYMap xyMap)
Performs bilinear interpolation for upscaling an image.
void bilinearExpandPowerOf2(const CRGB *input, CRGB *output, uint8_t inputWidth, uint8_t inputHeight, XYMap xyMap)
Performs bilinear interpolation for upscaling an image.
Functions to generate and fill arrays with noise.
Fast, efficient random number generators specifically designed for high-performance LED programming.
Expands a grid using bilinear interpolation and scaling up.
Representation of an RGB pixel (Red, Green, Blue)