-
-
Save gnkarn/ddf0f4381c38acf300c1c52bfb8b9258 to your computer and use it in GitHub Desktop.
RGB Sinusoids
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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