Created
March 8, 2018 10:42
-
-
Save m0wh/3e51ca4d946b316c763bc6b62a8a922b to your computer and use it in GitHub Desktop.
Rezz's goggles animations
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
int ringRadius[] = {90,55,15}; | |
color c = color(0, 255, 0); | |
int a = 0; | |
int speed = 10; | |
color white = color(255,255,255); | |
void setup() { | |
size(500,500); | |
background(30); | |
pixelDensity(2); // if you have a retina screen | |
} | |
void draw() { | |
colorMode(HSB); | |
c = color(frameCount%255, 255, 255); | |
translate(width/2, height/2); | |
rotate(PI/4); | |
background(30,30,30,.5); | |
stroke(15); | |
noFill(); | |
strokeWeight(14); | |
strokeCap(SQUARE); | |
line(0,15,0,95); | |
line(15,0,95,0); | |
line(0,-95,0,-15); | |
line(-95,0,-15,0); | |
strokeWeight(24); | |
ellipse(0,0,ringRadius[0]*2,ringRadius[0]*2); | |
ellipse(0,0,ringRadius[1]*2,ringRadius[1]*2); | |
ellipse(0,0,ringRadius[2]*2,ringRadius[2]*2); | |
noStroke(); | |
if(a <= 550) { | |
anim1(); | |
} else if(a <= 1000) { | |
anim2(); | |
} else { | |
anim3(); | |
} | |
a++; | |
if(a >= 1200) { | |
a = 0; | |
} | |
} | |
void anim3() { | |
// d 24 16 4 | |
// v 1/2 1/3 1/12 | |
// t 48 48 48 | |
frameRate(2*speed); | |
for(int i = 0; i < 20; i++) { | |
setLed(round(random(88)), color(random(255),255,200)); | |
} | |
setLed(light(2,(frameCount/12-1)%4), white); | |
setLed(light(2,(frameCount/12+1)%4), white); | |
setLed(light(2,(frameCount/12)%4), white); | |
setLed(light(2,(frameCount/12+2)%4), white); | |
setLed(light(1,(frameCount/3)%16), white); | |
setLed(light(1,(frameCount/3+4)%16), white); | |
setLed(light(1,(frameCount/3+8)%16), white); | |
setLed(light(1,(frameCount/3+12)%16), white); | |
setLed(light(0,(frameCount/2)%24), white); | |
setLed(light(0,(frameCount/2+6)%24), white); | |
setLed(light(0,(frameCount/2+12)%24), white); | |
setLed(light(0,(frameCount/2+18)%24), white); | |
} | |
void anim2() { | |
frameRate(6*speed); | |
for(int i = 0; i < 3; i++) { | |
setLed(light(2,(frameCount/8+i-1)%4), c); | |
} | |
for(int i = 0; i < 3; i++) { | |
setLed(light(1,(frameCount/3+i+2)%16), c); | |
setLed(light(1,(frameCount/3+i+8+2)%16), c); | |
} | |
for(int i = 0; i < 4; i++) { | |
setLed(light(0,(frameCount/2+i)%24), c); | |
setLed(light(0,(frameCount/2+i+12)%24), c); | |
} | |
} | |
void anim1() { | |
frameRate(6*speed); | |
for(int i = 0; i < 3; i++) { | |
setLed(light(2,(frameCount/6+i-1)%4), c); | |
} | |
for(int i = 0; i < 3; i++) { | |
setLed(light(1,16-(frameCount/4+i)%16), c); | |
setLed(light(1,16-(frameCount/4+i+8)%16), c); | |
} | |
for(int i = 0; i < 4; i++) { | |
setLed(light(0,(frameCount/2+i)%24), c); | |
setLed(light(0,(frameCount/2+i+12)%24), c); | |
} | |
} | |
int light(int r, int l) { | |
int a = 100; | |
switch(r) { | |
case 0: | |
a = l; | |
break; | |
case 1: | |
a = l+24; | |
break; | |
case 2: | |
a = l+24+16; | |
break; | |
} | |
return a; | |
} | |
void setLed(int led, color c) { | |
int ring = 0; | |
int ledInRing; | |
float angle = 0; | |
if(led < 24) { | |
ring = 0; | |
ledInRing = led; | |
angle = ledInRing*PI/12; | |
} else if(led < 16+24) { | |
ring = 1; | |
ledInRing = led-24; | |
angle = ledInRing*PI/8; | |
} else if(led < 4+16+24){ | |
ring = 2; | |
ledInRing = led-24-16; | |
angle = ledInRing*PI/2; | |
} | |
fill(c); | |
ellipse(sin(angle)*ringRadius[ring], cos(angle)*ringRadius[ring], 8.2, 8.2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment