Skip to content

Instantly share code, notes, and snippets.

@macegr
Created January 10, 2017 23:57
Show Gist options
  • Save macegr/32df4a60a710f8496f72470dd38d42b1 to your computer and use it in GitHub Desktop.
Save macegr/32df4a60a710f8496f72470dd38d42b1 to your computer and use it in GitHub Desktop.
slantMello glitch scrolling bars for RGB Shades code
// Draw slanting bars scrolling across the array
void slantMello() {
static byte slantPos = 0;
static byte distortDelay;
static byte changeDelay = 10;
static byte lastoffset = 1;
static uint16_t slowcolor = 0;
// startup tasks
if (effectInit == false) {
effectInit = true;
effectDelay = 5;
distortDelay = 10;
selectRandomPalette();
}
// pseudorandom seed
uint8_t ry = lastoffset;
uint8_t posoffset;
ry ^= (ry << 7);
ry ^= (ry >> 5);
ry ^= (ry << 3);
if (--distortDelay < 1) {
distortDelay = random(5,40);
lastoffset = ry;
if (--changeDelay < 1) {
changeDelay = random8(100,255);
selectRandomPalette();
}
}
for (byte y = 0; y < kMatrixHeight; y++) {
// pseudorandom offset
ry ^= (ry << 7);
ry ^= (ry >> 5);
ry ^= (ry << 3);
posoffset = ry / 4;
for (byte x = 0; x < kMatrixWidth; x++) {
byte pcolor = cubicwave8(x * 32 + y * 32 + slantPos + (posoffset-64));
leds[XY(x, y)] = ColorFromPalette(currentPalette, pcolor/4+slowcolor/64, pcolor*(pcolor > 16));
}
}
slowcolor+=4;
slantPos -= 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment