Created
December 9, 2018 18:16
-
-
Save hpwit/5b9df75a0aae6dcb7387e3ea2ae1075f to your computer and use it in GitHub Desktop.
CODE FOR ANIMATION
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
void PixelOn(int x,int y,CRGB Color) | |
{ | |
if (x<0 or y<0 or x>=LED_WIDTH or y>=LED_HEIGHT) | |
return ; | |
if(y%2==0) | |
leds[x+y*LED_WIDTH]=Color; | |
else | |
{ | |
leds[(LED_WIDTH<<1) * ((y >>1) + 1) - 1 - x]=Color; | |
} | |
} | |
long r=0; | |
void loop() | |
{ | |
//anim 1 | |
float ab=(float)(r/10)*2*PI/720; | |
int offx=-LED_WIDTH*(sin(3*ab)+1)/2; | |
int offy=-LED_HEIGHT*(sin(10*ab)+1)/2; | |
//these offset are used to have the pattern move around the panel also just a bit more fun. you can change this | |
for(int x1=1;x1<LED_WIDTH-1;x1++) | |
for(int y1=0;y1<LED_HEIGHT;y1++) | |
{ | |
int x=x1+offx; | |
int y=y1+offy; | |
int coloor= | |
( | |
sin8(x * 9.0) | |
+ sin8(y *5.0) | |
+ sin8((x + y) *10.0) | |
+ sin8(sqrt(double(x * x + y * y)) * 6.0) | |
) / 4; | |
PixelOn(x1,y1,CHSV((coloor+r)%256,255,255)); | |
} | |
r=r+5; | |
//anim2 | |
for(int x1=1;x1<LED_WIDTH-1;x1++) | |
for(int y1=0;y1<LED_HEIGHT;y1++) | |
{ | |
int coloor= int(sin8(sqrt(((x1-(triwave8(r/5) + LED_WIDTH) / 2.0) * (x1-(triwave8(r/5) + LED_WIDTH) / 2.0) + (y1 - LED_HEIGHT / 2.0) * (y1 - LED_HEIGHT / 2.0)) )*5)); | |
PixelOn(x1,y1,CHSV((coloor+r)%256,255,255)); | |
} | |
r=r+5; | |
//anim3 | |
float ab=(float)(r/10)*2*PI/720; | |
int offx=-LED_WIDTH*(sin(3*ab)+1)/2; | |
int offy=-LED_HEIGHT*(sin(10*ab)+1)/2; | |
for(int x1=1;x1<LED_WIDTH-1;x1++) | |
for(int y1=0;y1<LED_HEIGHT;y1++) | |
{ | |
int x=x1+offx; | |
int y=y1+offy; | |
int coloor=(sin8((double)(x)*8 )+ sin8((double)(y)*8)) / 2; | |
PixelOn(x1,y1,CHSV((coloor+r)%256,255,255)); | |
} | |
r=r+5; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment