Created
February 9, 2012 21:15
-
-
Save sidgabriel/1783281 to your computer and use it in GitHub Desktop.
A really pretty processing sketch that uses lots of math and blending
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
//Authored By Sid Gabriel 2/2012. Open code, no license disclosed. | |
//To run this, just copy and paste into a blank processing window | |
//then hit "play". You can get the processing ide at processing.org | |
//This code was written for processing 2.0a4 and has runs | |
//for me in android mode on a Samsung Galaxy S as well in Java on | |
// the desktop. It doesn't launch in Javascript mode.JAVA2D probably | |
//isn't enough power for all the mapped blending. Make art. | |
int num = 128; | |
int colorL=220, k = 0, j=100, i=200; | |
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 = 420; | |
int counter2end = 733; | |
boolean staticLoc = true; | |
boolean undernum =false; | |
boolean mover =true; | |
boolean sect = true; | |
boolean mousect = false; | |
boolean perambulate = true; | |
boolean radio = true; | |
PImage gridness,symbiosis; | |
float gm = 1.6180339887498948482; | |
float gr = 1/gm; | |
boolean unitus=true; | |
boolean returned=false; | |
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; | |
PFont font; | |
PFont fontL; | |
void setup() | |
{ | |
symbiosis = loadImage("http://dl.dropbox.com/u/38921118/sybmbiosis.png"); | |
gridness = loadImage("http://dl.dropbox.com/u/38921118/sol2%202.png"); | |
size(800, 600, P3D); | |
// fs = new FullScreen(this); | |
tmx=-width*gr+width; | |
tmy=height*gr; | |
mx=-width*gr+width; | |
lmx=-width*gr+width; | |
//cam = new Capture(this, 640, 480, 30); | |
// cam.start(); | |
font = loadFont("http://dl.dropbox.com/u/38921118/PirulenRg-Regular-21.vlw"); | |
fontL = loadFont("http://dl.dropbox.com/u/38921118/PirulenRg-Regular-48.vlw"); | |
textFont(font); | |
textSize(21); | |
xofset=-width*gr+width; | |
yofset=height*gr; | |
my=height*gr; | |
lmy=height*gr; | |
frameRate(96); | |
smooth(); | |
loadPixels(); | |
} | |
void draw() | |
{//background(255); | |
//noCursor(); | |
counter1++; | |
if (counter1 == counter1end) { | |
returned=false; | |
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) { | |
tm=9; | |
//pictrans(); | |
// radio=false; | |
} | |
else { | |
// radio=true; | |
}; | |
if ((tn2>tn3)&&(m==9)) { | |
// pictrans(); | |
// save("generated"+"_"+month()+"_"+day()+"_m"+m+"n1"+n1+"n2"+n2+"n3"+n3+"e"+epi+"s"+step+"r"+r+"_"+millis()+second()+".png"); | |
tm=0; | |
} | |
if ((tn2>tn3)&&(m==0)) { | |
//pictrans(); | |
// save("generated"+"_"+month()+"_"+day()+"_m"+m+"n1"+n1+"n2"+n2+"n3"+n3+"e"+epi+"s"+step+"r"+r+"_"+millis()+second()+".png"); | |
tm=9; | |
// radio=true;//!radio; | |
// m=9; | |
// gridness = loadImage("http://theoneone.com/sourcerequires/overunitus.png"); | |
// tm=9; | |
// lm=9; | |
} | |
if (tn1>tn2) { | |
//unitus=true; | |
// save("generated"+"_"+month()+"_"+day()+"_m"+m+"n1"+n1+"n2"+n2+"n3"+n3+"e"+epi+"s"+step+"r"+r+"_"+millis()+second()+".png"); | |
tm=9; | |
} | |
else { | |
//unitus=false; | |
} | |
if (tn1>tn3) { | |
//undernum=true; | |
// save("generated"+"_"+month()+"_"+day()+"_m"+m+"n1"+n1+"n2"+n2+"n3"+n3+"e"+epi+"s"+step+"r"+r+"_"+millis()+second()+".png"); | |
tm=9; | |
} | |
else { | |
// undernum=false; | |
} | |
if (tn3<tn1+tn2) { | |
// sect=true; | |
// save("generated"+"_"+month()+"_"+day()+"_m"+m+"n1"+n1+"n2"+n2+"n3"+n3+"e"+epi+"s"+step+"r"+r+"_"+millis()+second()+".png"); | |
tm=0; | |
} | |
else { | |
// sect=false; | |
} | |
counter1 = 0; | |
} | |
counter2++; | |
if (counter2 == counter2end) { | |
mover=!mover; | |
counter2 = 0; | |
returned=false; | |
} | |
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(mouseX, 0,width,.055,3.78); | |
//n2=map(mouseX, 0,width,1.22,3.98); | |
//n3=map(mouseX, 0,width,1.1567,7.149); | |
// epi=map(mouseY, 0,height,200,900); | |
//step=map(mouseY, 0,height,9.84578,12.76890); | |
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); | |
} | |
tint(epi*n3, epi*n2, epi*n1, (n1+n2+n3)*gm); | |
// if (cam.available() == true) { | |
// cam.read(); | |
// image(cam, 0, 0, width, height); | |
// The following does the same, and is faster when just drawing the image | |
// without any additional resizing, transformations, or tint. | |
//set(0, 0, cam); | |
pushMatrix(); | |
//image(gridness, 0, 0, width, height); | |
tint(epi*n3, epi*n2, epi*n1, (n1+n2+n3)*gr); | |
fill(0, (n1+n2+n3)*gm); | |
rect(0,0,width,height); | |
if(returned){ | |
scale(-1,1); | |
image(gridness, -0, 0, -width, height); | |
}else{image(gridness, 0, 0, width, height); | |
} | |
tint(epi*n3, epi*n2, epi*n3, (n1+n2+n3)*gm); | |
fill(epi*n3, epi*n2, epi*n3, (n1+n2+n3)*gm); | |
if(perambulate){ | |
imageMode(CENTER); | |
tint(epi*n3, epi*n2, epi*n3, (n1+n2+n3)*gm); | |
image(symbiosis,xofset,yofset); | |
imageMode(CORNERS); | |
} | |
image(gridness, 0, 0, width, height); | |
textFont(font); | |
textSize(17); | |
text("p y r a m i d e c l i p s e . c o m ",map(epi,lepi,tepi,30,36),20);//((width/2)*gr)/2,20); | |
text("m a y 1 7 - 2 2 ",(width/2)*gr,height-20); | |
textFont(fontL); | |
textSize(48); | |
text(" SYMBIOSIS", | |
map(n1,ln1,tn1,width-(width*gr),width-(width*gr)+5),height*gr); | |
textSize(21); | |
text("Pyramid Lake, Nevada 2012", | |
map(n1,ln1,tn1,width-(width*gr)-5, width-(width*gr)+5),height*gr+20); | |
popMatrix(); | |
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)*gm); | |
strokeWeight(n1);//n2); | |
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)); | |
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(n2));//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(n2));//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 (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, (n1+n2+n3)*gr);//sq(n3*gm)); | |
// if (r>=1000) { | |
// reStore(); | |
// } | |
// if (cam.available() == true) { | |
// cam.read(); | |
// image(cam, 0, 0, width, height); | |
// The following does the same, and is faster when just drawing the image | |
// without any additional resizing, transformations, or tint. | |
//set(0, 0, cam); | |
pushMatrix(); | |
fill(0, (n1+n2+n3));//sq(n3*gm)); | |
rect(0,0,width,height); | |
tint(epi*n1, epi*n2, epi*n3, (n1+n2+n3)*gm);//sq(n3*gm)); | |
image(gridness, 0, 0, width, height); | |
if(returned){ | |
scale(-1,1); | |
image(gridness, -0, 0, -width, height); | |
}else{ | |
image(gridness, 0, 0, width, height); | |
} | |
// image(gridness, 0, 0, width, height); | |
fill(epi*n3, epi*n2, epi*n3, (n1+n2+n3)*gm);//sq(n3*gm)); | |
textFont(font); | |
textSize(17); | |
text("p y r a m i d e c l i p s e . c o m ",map(epi,lepi,tepi,30,36),20);//((width/2)*gr)/2,20); | |
text("m a y 1 7 - 2 2 ",(width/2)*gr,height-20); | |
textFont(fontL); | |
textSize(48); | |
text(" SYMBIOSIS", | |
map(n1,ln1,tn1,width-(width*gr),width-(width*gr)+5),height*gr); | |
textSize(21); | |
text("Pyramid Lake, Nevada 2012", | |
map(n1,ln1,tn1,width-(width*gr)-5, width-(width*gr)+5),height*gr+20); | |
if(perambulate){ | |
// imageMode(CENTER); | |
//tint(epi*n2, epi*n3, epi*n2, (n1+n2+n3)*gr); | |
//image(symbiosis,xofset,yofset); | |
//imageMode(CORNERS); | |
} | |
popMatrix(); | |
//} | |
} | |
//void mousePressed() { | |
// if (mouseButton == RIGHT) { | |
// staticLoc=!staticLoc; | |
// counter1=0; | |
// } | |
// else { | |
// | |
// if (counter1end < counter1) { | |
// counter1 = counter1end-10; | |
// } | |
// else { | |
// counter1 = counter1end+1; | |
// } | |
// link("http://www.pyramideclipse.com/visions/", "_new"); | |
// | |
// } | |
//} | |
void keyPressed() { | |
if (key == 'O') { | |
gridness = loadImage("http://dl.dropbox.com/u/38921118/sol2%202.png"); | |
} | |
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 == 'r') { | |
returned=!returned; | |
} | |
if (key == 'B') { | |
gridness = loadImage("http://dl.dropbox.com/u/38921118/sol2%202.png"); | |
} | |
if (key == 'P') { | |
gridness = loadImage("http://dl.dropbox.com/u/38921118/sol2%202.png"); | |
} | |
if (key == 'A') { | |
gridness = loadImage("http://dl.dropbox.com/u/38921118/sol2%202.png"); | |
} | |
if (key == 'C') { | |
// save("prophecy.png"); | |
// gridness = cam;//loadImage("http://theoneone.com/sourcerequires/prophecy.png"); | |
} | |
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') { | |
tm=21; | |
m=0; | |
lm=3; | |
} | |
if (key == '2') { | |
restoration(); | |
} | |
if (key == '3') { | |
tm=3; | |
m=3; | |
lm=3; | |
} | |
if (key == '7') { | |
tm=9; | |
m=7; | |
lm=7; | |
} | |
if (key == '9') { | |
tm=9; | |
m=9; | |
lm=9; | |
} | |
if (key == '0') { | |
tm=0; | |
m=0; | |
lm=0; | |
} | |
if (key == '#') { | |
tm=21; | |
m=21; | |
lm=21; | |
} | |
if (key == '5') { | |
tm=5; | |
m=5; | |
lm=5; | |
} | |
if (key == '4') { | |
tm=21; | |
m=9; | |
lm=1; | |
} | |
} | |
void pictrans() { | |
int caseint = int(random(3, 6)); | |
switch(caseint) { | |
case 0: | |
break; | |
case 3: | |
gridness = loadImage("http://dl.dropbox.com/u/38921118/sol2%202.png"); | |
//undernum=true; | |
break; | |
case 4: | |
gridness = loadImage("http://dl.dropbox.com/u/38921118/sol2%202.png"); | |
break; | |
case 5: | |
gridness = loadImage("http://dl.dropbox.com/u/38921118/sol2%202.png"); | |
break; | |
case 6: | |
gridness = loadImage("http://dl.dropbox.com/u/38921118/sol2%202.png"); | |
break; | |
} | |
} | |
void restoration() { | |
// tm=random(1.124816,21.124816); | |
if (perambulate) { | |
if (mover) { | |
tmx=random(width*.3, width*.7); | |
tmy=random(height*.3, height*.7); | |
} | |
else { | |
tmx=lmx; | |
tmy=lmy; | |
} | |
} | |
else { | |
tmx=lmx; | |
tmy=lmy; | |
} | |
tm=m;//random(5,9); | |
tn1=random(width*.002)*gm; | |
// println(tn1); | |
tn2=random(height*.003)*gm; | |
// println(tn2); | |
tn3=random(width*.004)*gm; | |
// println(tn3); | |
tepi=random(width*.3, width*.7); | |
// println("w"+width+"gr"+gr+"gm"+gm+"epi"+tepi); | |
tstep=random((width*gr)/8, (width*gm)/8); | |
lm=m; | |
tmx=width*.39; | |
tmy=height*.19; | |
mx=width*.36; | |
lmx=width*.36; | |
tm=9.0; | |
tn1=0.49204814; | |
tn2=1.4225979; | |
tepi=381.3653; | |
tstep=21.530817; | |
m=map(counter1, 1, counter1end, lm, tm); | |
ln1=0.1829839; | |
ln2=3.638218; | |
lepi=347.85712; | |
lstep=2.100946; | |
counter1 = counter1end - 1; | |
} | |
void reStore() { | |
if (perambulate) { | |
if (mover) { | |
tmx=random(width*.3, width*.7); | |
tmy=random(height*.3, 320); | |
} | |
else { | |
tmx=lmx; | |
tmy=lmy; | |
} | |
} | |
else { | |
tmx=lmx; | |
tmy=lmy; | |
} | |
tm=m;//random(5,9); | |
tn1=random(width*.002)*gm; | |
// println(tn1); | |
tn2=random(height*.003)*gm; | |
// println(tn2); | |
tn3=random(width*.004)*gm; | |
// println(tn3); | |
tepi=abs(random(width*.8, width*.9))*3; | |
// println("w"+width+"gr"+gr+"gm"+gm+"epi"+tepi); | |
tstep=abs(random(.1,1.)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment