Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.