Skip to content

Instantly share code, notes, and snippets.

@StefanPetrick
Created July 19, 2017 15:21
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save StefanPetrick/dc666c1b4851d5fb8139b73719b70149 to your computer and use it in GitHub Desktop.
Save StefanPetrick/dc666c1b4851d5fb8139b73719b70149 to your computer and use it in GitHub Desktop.
RGB Sinusoids
float speed = 0.3; // speed of the movement along the Lissajous curves
float size = 3; // amplitude of the curves
for (uint8_t y = 0; y < Height; y++) {
for (uint8_t x = 0; x < Width; x++) {
float cx = y + float(size * (sinf (float(speed * 0.003 * float(millis() ))) ) ) - 8; // the 8 centers the middle on a 16x16
float cy = x + float(size * (cosf (float(speed * 0.0022 * float(millis()))) ) ) - 8;
float v = 127 * (1 + sinf ( sqrtf ( ((cx * cx) + (cy * cy)) ) ));
uint8_t data = v;
leds[XY(x, y)].r = data;
cx = x + float(size * (sinf (speed * float(0.0021 * float(millis()))) ) ) - 8;
cy = y + float(size * (cosf (speed * float(0.002 * float(millis() ))) ) ) - 8;
v = 127 * (1 + sinf ( sqrtf ( ((cx * cx) + (cy * cy)) ) ));
data = v;
leds[XY(x, y)].b = data;
cx = x + float(size * (sinf (speed * float(0.0041 * float(millis() ))) ) ) - 8;
cy = y + float(size * (cosf (speed * float(0.0052 * float(millis() ))) ) ) - 8;
v = 127 * (1 + sinf ( sqrtf ( ((cx * cx) + (cy * cy)) ) ));
data = v;
leds[XY(x, y)].g = data;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment