Created
February 9, 2012 03:34
-
-
Save sidgabriel/1777058 to your computer and use it in GitHub Desktop.
Applying Effects to Live Solar Imaging In Processing
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
import fullscreen.*; | |
import japplemenubar.*; | |
int num = 180; | |
float x, y, z; | |
float lmx,mx,xofset; | |
float lmy,my,yofset; | |
float r, th=0, step,lstep=.1, epi,lepi=400; | |
float m,tm,lm = 9, n1,ln1=1, n2,ln2=0, n3,ln3=0; | |
float b=1, a=1; | |
int counter1=0, counter2=0; | |
int counter1end = 360; | |
int counter2end = 720; | |
boolean staticLoc = true; | |
boolean undernum =false; | |
boolean mover =true; | |
boolean sect = false; | |
boolean mousect = false; | |
boolean nasaupdate = true; | |
boolean perambulate = true; | |
boolean radio = true; | |
PImage gridness, gridness2, nasa, nasa1,nasa2,nasa3,nasa4,nasa5; | |
float gm = 1.6180339887498948482; | |
float gr = 1/gm; | |
boolean unitus=true; | |
float tn1=random(1.7); | |
float tn2=random(2.9); | |
float tn3=random(3.7); | |
float tepi=random(217, 371); | |
float tstep=random(1.47, 2.17); | |
float tmx,tmy; | |
FullScreen fs; | |
boolean stay = true; | |
void setup() | |
{ | |
gridness = loadImage("http://sdo.gsfc.nasa.gov/assets/img/latest/latest_1024_0335.jpg"); | |
gridness2 = loadImage("http://sdo.gsfc.nasa.gov/assets/img/latest/latest_1024_0335.jpg"); | |
size(777,777,P3D); | |
fs = new FullScreen(this); | |
tmx=width*.39; | |
tmy=height*gr; | |
mx=width*.36; | |
lmx=width*.36; | |
background(0); | |
xofset=width*.37; | |
yofset=height*.18; | |
my=height*gr; | |
lmy=height*gr; | |
frameRate(33); | |
smooth(); | |
loadPixels(); | |
} | |
void draw() | |
{if(nasaupdate){nasaUpdate();} | |
noCursor(); | |
counter1++; | |
if (counter1 == counter1end) { | |
lm=tm; | |
ln1=tn1; | |
ln2=tn2; | |
ln3=tn3; | |
lepi=tepi; | |
lstep=tstep; | |
lmx=mx; | |
lmy=my; | |
mx=tmx; | |
my=tmy; | |
m=tm; | |
n1=tn1; | |
n2=tn2; | |
n3=tn3; | |
epi=tepi; | |
step=tstep; | |
reStore(); | |
if(tn2>tn3){ | |
//picTrans(); | |
//radio=false; | |
}else{ | |
//radio=true; | |
}; | |
if((tn2>tn3)&&(m==9)){ | |
picGrind(); | |
m=9;tm=9;lm=9; | |
} | |
if((tn2>tn3)&&(m==0)){ | |
picTrans(); | |
//radio=true;//!radio; | |
m=9; | |
// gridness = loadImage("http://theoneone.com/sourcerequires/overunitus.png"); | |
tm=9; | |
lm=9; | |
} | |
if(tn1>tn2){ | |
//unitus=true; | |
//radio=false; | |
picGrind(); | |
}else{ | |
//unitus=false; | |
} | |
if(tn1>tn3){ | |
picTrans(); | |
//undernum=true; | |
}else{ | |
//undernum=false; | |
} | |
if(tn3<tn1+tn2){ | |
//sect=true; | |
//radio=false; | |
picGrind(); | |
} else { | |
//sect=false; | |
picTrans(); | |
} | |
counter1 = 0; | |
} | |
counter2++; | |
if (counter2 == counter2end) { | |
//mover=!mover; | |
counter2 = 0; | |
picTrans(); | |
} | |
m=map(counter1, 1,counter1end,lm,tm); | |
if(mover){ mx=map(counter1, 1,counter1end,int(lmx),int(tmx)); | |
my=map(counter1, 1,counter1end,int(lmy),int(tmy));}else{ | |
mx=map(counter1, 1,counter1end,(lmx),(tmx));//(tmx*gr)); | |
my=map(counter1, 1,counter1end,(lmy),(tmy));//(tmy*gr)); | |
} | |
xofset=mx;//println(mx); | |
yofset=my;//println(my); | |
if(undernum){ | |
n1=map(counter1, 1,counter1end,n1,tn1); | |
n2=map(counter1, 1,counter1end,n2,tn2); | |
n3=map(counter1, 1,counter1end,n3,tn3); | |
epi=map(counter1, 1,counter1end,epi,tepi); | |
step=map(counter1, 1,counter1end,step,tstep); | |
}else{ | |
n1=map(counter1, 1,counter1end,ln1,tn1); | |
n2=map(counter1, 1,counter1end,ln2,tn2); | |
n3=map(counter1, 1,counter1end,ln3,tn3); | |
epi=map(counter1, 1,counter1end,lepi,tepi); | |
step=map(counter1, 1,counter1end,lstep,tstep); | |
} | |
if(mousect){ | |
// n1=map(counter1, 1,counter1end,ln1*gr,tn1*gm); | |
//n2=map(counter1, 1,counter1end,ln2*gr,tn2*gm); | |
//n3=map(counter1, 1,counter1end,ln3*gr,tn3*gm); | |
epi=map(counter1, 1,counter1end,lepi*10,tepi*10); | |
// step=map(counter1, 1,counter1end,lstep*gr,tstep*gm); | |
} | |
tint(epi*n3, epi*n2,epi*n1,(n1+n2+n3)*gm); | |
image(gridness,0,0,width,height); | |
if(stay){xofset = width/2;}//yofset=height/2;} | |
if(staticLoc){translate(xofset,yofset);}else{translate(mouseX, mouseY);println(width+":w m:"+mouseX);}//width/2,height/4) | |
//box(50); | |
//strokeWeight(10); | |
//point(mouseX,mouseY); | |
// noStroke(); | |
noFill(); | |
beginShape(); | |
for (int i=1; i < num; i++) { | |
r = (epi*n1)*pow(((pow(abs(cos(m*th/4)/a), abs(n2)))+(pow(abs(sin(m*th/4)/b), abs(n3)))), (-1/n1)); | |
th = th + step; | |
x = r*cos(th); | |
y = r*sin(th); | |
stroke(abs(epi+r)*gr,abs(epi+r)*gr,abs(epi+r)*gr, abs(n1*gr)); | |
strokeWeight(n1);//n2); | |
if(sect){vertex(x,y); | |
vertex(radians(x),radians(y));}else{ | |
curveVertex(x, y); | |
if(radio){curveVertex(radians(x), radians(y));} | |
} | |
// curveVertex(x, y); | |
// if(radio){curveVertex(radians(x), radians(y));} | |
} | |
if(unitus){endShape(CLOSE); beginShape();} | |
for (int i=1; i < num; i++) { | |
r = (epi*n2)*pow(((pow(abs(cos(m*th/4)/a), n2))+(pow(abs(sin(m*th/4)/b), n3))), (-1/n1)); | |
th = th + step; | |
x = r*cos(th); | |
y = r*sin(th); | |
stroke(abs(epi)*r*gm,abs(epi)*r*gm,abs(epi)*r*gm, abs(n2*gr)); | |
strokeWeight(n1); | |
curveVertex(x, y); | |
if(radio){curveVertex(radians(x), radians(y));} | |
} | |
if(unitus){endShape(CLOSE); beginShape();} | |
for (int i=1; i < num; i++) { | |
r = (epi*n3)*pow(((pow(abs(cos(m*th/4)/a), n2))+(pow(abs(sin(m*th/4)/b), n3))), (-1/n1)); | |
th = th + step; | |
x = r*cos(th); | |
y = r*sin(th); | |
stroke(abs(epi)*(r*gr),abs(epi)*(r*gr),abs(epi)*(r*gr), abs(n3*gr)); | |
strokeWeight(abs(n1));//n2); | |
curveVertex(x, y); | |
if(radio){curveVertex(radians(x), radians(y));} | |
} | |
if(unitus){endShape(CLOSE); beginShape();} | |
//endShape(CLOSE); | |
// beginShape(); | |
for (int i=1; i < num; i++) { | |
r = (epi)*pow(((pow(abs(cos(m*th/4)/a), n2))+(pow(abs(sin(m*th/4)/b), n3))), (-1/n1)); | |
th = th + step; | |
x = r*cos(th); | |
y = r*sin(th); | |
stroke(abs(epi)*(r*gr),abs(epi)*(r*gr),abs(epi)*(r*gr), abs(n3*gr)); | |
strokeWeight(abs(n1));//n2); | |
if(sect){vertex(x,y); | |
vertex(radians(x),radians(y));}else{ | |
curveVertex(x, y); | |
if(radio){curveVertex(radians(x), radians(y));} | |
} | |
} | |
endShape(CLOSE); | |
if(stay){xofset = width/2;}//yofset=height/2;} | |
if(staticLoc){ | |
translate(0-xofset,0-yofset);//width*2-mouseX,height*4-mouseY); | |
}else{ | |
translate(width-mouseX,height-mouseY);//println(width+":w m:"+mouseX);//////println(" "+mouseX+"w h"+mouseY+" "); | |
} | |
tint(epi*n1,epi*n2,epi*n3,(n3)*gm);//sq(n3*gm)); | |
image(gridness2,0,0,width,height); | |
fill(epi/2,epi/2,epi/2,(n1+n2+n3)/3);//sq(n3*gm)); | |
rect(0,0,width,height); | |
//if(r>=1000){reStore();} | |
} | |
void mousePressed() { | |
if(mouseButton == RIGHT){ | |
staticLoc=!staticLoc; | |
counter1=0; | |
}else{ | |
if (counter1end < counter1) { | |
counter1 = counter1end-10; | |
} | |
else { | |
counter1 = counter1end+1; | |
} | |
} | |
} | |
void keyPressed() { | |
if (key == 'O'){ | |
gridness2 = gridness; | |
gridness = nasa1; | |
} | |
if (key == 'M'){ | |
if (counter2end < counter2) { | |
counter2 = counter2end-1; | |
} | |
else { | |
counter2 = counter2end+1; | |
} | |
} | |
if (key == 'U'){ | |
//mousect=!mousect; | |
undernum=!undernum; | |
} | |
if (key == 'L'){ | |
perambulate=!perambulate; | |
} | |
if (key == 'S'){ | |
unitus=!unitus; | |
} | |
if (key == 'T'){ | |
sect=!sect; | |
} | |
if (key == 'R'){ | |
radio=!radio; | |
} | |
if (key == 'B'){ | |
gridness2 = gridness; | |
gridness = nasa1; | |
} | |
if (key == 'P'){ | |
gridness2 = gridness; | |
gridness = nasa3; | |
} | |
if (key == 'A'){ | |
gridness2 = gridness; | |
gridness = nasa2; | |
} | |
if (key == 'C'){ | |
gridness2 = gridness; | |
gridness = nasa1; | |
} | |
if (key == TAB){ | |
save("generated"+"_"+month()+"_"+day()+"_m"+m+"n1"+n1+"n2"+n2+"n3"+n3+"e"+epi+"s"+step+"r"+r+"_"+millis()+second()+".png"); | |
} | |
if (key == ' ') { | |
if (counter1end < counter1) { | |
counter1 = counter1end-1; | |
} | |
else { | |
counter1 = counter1end+1; | |
} | |
} if (key == '1') { | |
mousect = !mousect; | |
} | |
if (key == '2') { | |
restoration(); | |
} | |
if (key == '@') { | |
picGrind(); | |
} | |
if (key == '3') { | |
tm=3; | |
m=3; | |
lm=3; | |
} | |
if (key == '7') { | |
tm=7; | |
m=7; | |
lm=7; | |
} | |
if (key == '9') { | |
tm=9; | |
m=9; | |
lm=9; | |
} | |
if (key == '0') { | |
tm=0; | |
m=0; | |
lm=0; | |
} | |
if (key == '#') { | |
stay=!stay; | |
} | |
if (key == '5') { | |
nasaUpdate(); | |
} | |
if (key == '4') { | |
picTrans(); | |
} | |
} | |
void picTrans(){ | |
int caseint = int(random(1,6)); | |
switch(caseint) { | |
case 0: | |
break; | |
case 1: | |
gridness2 = gridness; | |
gridness = nasa1; | |
break; | |
case 2: | |
gridness2 = gridness; | |
gridness = nasa2; | |
break; | |
case 3: | |
gridness2 = gridness; | |
gridness = nasa3; | |
//undernum=true; | |
break; | |
case 4: | |
gridness2 = gridness; | |
gridness = nasa4; | |
break; | |
case 5: | |
gridness2 = gridness; | |
gridness = nasa5; | |
break; | |
case 6: | |
gridness2 = gridness; | |
gridness = nasa; | |
break; | |
} | |
} | |
void picGrind(){ | |
int caseint = int(random(1,6)); | |
switch(caseint) { | |
case 0: | |
break; | |
case 1: | |
gridness2.blend(gridness, 0, 0, gridness.width, gridness.height, 0,0,gridness.width,gridness.height, OVERLAY); | |
gridness = nasa1; | |
break; | |
case 2: | |
gridness2.blend(gridness, 0, 0, gridness.width, gridness.height, 0,0,gridness.width,gridness.height, EXCLUSION); | |
gridness = nasa2; | |
break; | |
case 3: | |
// gridness2.blend(gridness, 0, 0, gridness.width, gridness.height, 0,0,gridness.width,gridness.height, LIGHTEST); | |
gridness = nasa3; | |
//undernum=true; | |
break; | |
case 4: | |
// gridness2.blend(gridness, 0, 0, gridness.width, gridness.height, 0,0,gridness.width,gridness.height, DARKEST); | |
gridness = nasa4; | |
break; | |
case 5: | |
gridness2.blend(gridness, 0, 0, gridness.width, gridness.height, 0,0,gridness.width,gridness.height, HARD_LIGHT); | |
gridness = nasa5; | |
break; | |
case 6: | |
gridness2.blend(gridness, 0, 0, gridness.width, gridness.height, 0,0,gridness.width,gridness.height, SOFT_LIGHT); | |
gridness = nasa; | |
break; | |
} | |
} | |
void restoration(){ | |
float r, th=0, step,lstep=.1, epi,lepi=400; | |
float m,tm,lm = 9, n1,ln1=1, n2,ln2=0, n3,ln3=0; | |
float b=1, a=1; | |
int counter1=0, counter2=0; | |
int counter1end = 555; | |
int counter2end = 777; | |
reStore(); | |
} | |
void reStore(){ | |
if(perambulate){if(mover){tmx=random(width*.2,width*.8); | |
tmy=random(height*.2,height*.8);}else{tmx=lmx;tmy=lmy;}}else{tmx=lmx;tmy=lmy;} | |
if(stay){tmy=random(height/2,height*gr);} | |
tm=m;//random(5,9); | |
tn1=abs(random(width*.002))*gm; | |
// println(tn1); | |
tn2=abs(random(height*.003))*gm; | |
// println(tn2); | |
tn3=abs(random(width*.004))*gm; | |
// println(tn3); | |
tepi=abs(random(width*.7, width*.9))*3; | |
// println("w"+width+"gr"+gr+"gm"+gm+"epi"+tepi); | |
tstep=abs(random((width*gr)/8,(width*gm)/8)); | |
} | |
void nasaUpdate(){ | |
nasa = loadImage("http://sdo.gsfc.nasa.gov/assets/img/latest/f_HMImag_171_512.jpg"); | |
nasa1 = loadImage("http://sdo.gsfc.nasa.gov/assets/img/latest/f_304_211_171_512.jpg"); | |
nasa2 = loadImage("http://sdo.gsfc.nasa.gov/assets/img/latest/latest_512_0335.jpg"); | |
nasa3 = loadImage("http://sdo.gsfc.nasa.gov/assets/img/latest/latest_512_0211.jpg"); | |
nasa4 = loadImage("http://sdo.gsfc.nasa.gov/assets/img/latest/latest_512_0131.jpg"); | |
nasa5 = loadImage("http://sdo.gsfc.nasa.gov/assets/img/latest/latest_512_0193.jpg"); | |
nasaupdate=false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment