Thursday, March 6, 2008

PROJECT01 Asta - Jung























import processing.opengl.*;

import ddf.minim.*;
import ddf.minim.analysis.*;

AudioPlayer song;
BeatDetect beat;

float ang;
int limit = 1500;


int ball = 2000;
pelo[] lista ;
float[] z = new float[ball];
float[] phi = new float[ball];
float[] largos = new float[ball];
float radio = 100;
float rx = 0;
float ry =0;

float eRadius;


void setup(){
size(1000, 800, OPENGL);
radio = height/6;

lista = new pelo[ball];
for (int i=0; i*<*ball; i++){
lista[i] = new pelo();
}
noiseDetail(2);


//add your song!
Minim.start(this);
song = Minim.loadFile("DJ Son & Potlatch - Self Portrait.mp3");
song.play();
// a beat detection object song SOUND_ENERGY mode with a sensitivity of 10 milliseconds
beat = new BeatDetect();

ellipseMode(CENTER_RADIUS);
eRadius = 20;
}

void draw()
{
background(255);
translate(width/2,height/2);

float rxp = ((mouseX-(width/2))*0.005);
float ryp = ((mouseY-(height/2))*-0.005);
rx = (rx*0.9)+(rxp*0.15);
ry = (ry*0.9)+(ryp*0.15);
rotateY(rx);
rotateX(ry);
fill(255);
noStroke();
sphere(radio);

for (int i=0;i{ball;i++){
lista[i].dibujar();

beat.detect(song.mix);
float a = map(eRadius, 20, 80, 60, 255);
fill(60, 55, 110, a);
if ( beat.isOnset() ) eRadius = 300;

ellipse(width/2, height/2, eRadius, eRadius);
eRadius *= 0.95;
if ( eRadius < 20 ) eRadius = 20;

}
}


class pelo
{
float z = random(-radio,radio);
float phi = random(TWO_PI);
float largo = random(4,1.2);
float theta = asin(z/radio/3);

void dibujar(){

float off = (noise(millis() * 0.0005,sin(phi))-0.5) * 0.3;
float offb = (noise(millis() * 0.0007,sin(z) * 0.01)-0.5) * 0.3;

float thetaff = theta+off;
float phff = phi+offb;
float x = radio * cos(theta) * cos(phi);
float y = radio * cos(theta) * sin(phi);
float z = radio * sin(theta);
float msx= screenX(x,y,z);
float msy= screenY(x,y,z);

float xo = radio * cos(thetaff) * cos(phff);
float yo = radio * cos(thetaff) * sin(phff);
float zo = radio * sin(thetaff);

float xb = xo * largo;
float yb = yo * largo;
float zb = zo * largo;

beginShape(LINES);
stroke(130,140,10,30);
vertex(x,y,z);
stroke(230,80);
vertex(xb,yb,zb);

endShape();
}
}

void keyPressed(){
if (key=='s'){
saveFrame("project-####.jpg"); //saves the image in documents
}
}


for i *<* ball take out either *<* and replace with just < or { and replace with <; had some trouble posting the script to the blog, blog thought it was HTML!

Friday, February 8, 2008

classes and functions



Students [] stu = new Students [16];

void setup(){
size(screen.width,screen.height); //full screen

//for(int i=0;i<15;i++){
//stu[i]=new Students();
//}
stu[0]=new Students(60,57,1,100,0,0);
stu[1]=new Students(58,45,2,150,0,1); //me!
stu[2]=new Students(60,42,3,100,0,1);
stu[3]=new Students(57,40,4,200,0,1);
stu[4]=new Students(58,70,1,100,0,0);
stu[5]=new Students(61,92,3,800,0,0);
stu[6]=new Students(62,91,PI,400,0,0);
stu[7]=new Students(55,40,5,200,0,0);
stu[8]=new Students(59,100,random(1,10),100,0,0);
stu[9]=new Students(54,20,1,1,0,1);
stu[10]=new Students(59,50,2.5,500,0,0);
stu[11]=new Students(54,20,PI,200,0,1);
stu[12]=new Students(58,60,3,250,0,0);
stu[13]=new Students(54,48,3,300,0,1);
stu[14]=new Students(10,101,PI/2,200,0,0);
stu[15]=new Students(59,40,PI,100,0,0);

for(int i=0;i<16;i++){
stu[i].x=map(i,0,16,0,width);

//stu[i].x=i*30;
}
}


void draw(){
fill(255,20);
rect(0,0,width,height);
for(int i=0;i<16;i++){
stu[i].appearance();
stu[i].performance(mouseY);


}

}

class Students{
float sHeight;
float sWeight;
float sIntel;
float sSexiness;
float x;
float sex;

float jiggle;

//constructor, takes values you send to class
//when you are constructing them.. feeds variables
Students (float h, float w, float i, float ss, float x, float s){
sHeight=h;
sWeight=w;
sIntel=i;
sSexiness=ss;
x=x;
sex=s;
}

void appearance(){
pushMatrix();
translate(x,height/2-sIntel);
rotate(sSexiness*sIntel+jiggle);

fill(sSexiness,50);
rect(0,0,sWeight,sHeight);

popMatrix();
}

void performance(float jig){
//rotate rectangle
jiggle=random(radians(1),radians(jig));
//change transparency

}


}


void keyPressed(){
if (key=='s'){
saveFrame("week3-####.jpg"); //saves the image in documents
}
}

Friday, February 1, 2008


Spot [] sp= new Spot [100];


void setup(){
size (500,500);
smooth();
noStroke();


for(int i=0; i<50;>
sp[i] = new Spot(random(width),random(height),random(5,75), color(int(random(170)),150,110) ); //construct the object
}
}

void draw(){
//background(0);
fill(70,20);
rect (0,0,width, height); //leaves a "residue" when the lines moves

for(int i=0; i<50;>
sp[i].display();
sp[i].update();
for(int j=0; j<50;>
sp[i].drawLines(sp[i].x, sp[i].y, sp[j].x, sp[j].y);
}
}
}

class Spot{ //declaring a new class named spot
float x, y; //the x- and y-coordinate
float diameter; //diameter of the circle
color fColor;
boolean goingRight=true; //setting up local variables for class

//constructor so that the beginning spot at top doesn't need
//the excessive variables listed - it gets information from here.
Spot(float xpos, float ypos, float dia, color fillColor){
x=xpos;
y=ypos;
diameter=dia;
fColor=fillColor;
}

//sets up the connector lines to attract to the circles
void drawLines(float x1, float y1, float x2, float y2){
float distance=dist(x1,y1,x2,y2);
if(distance<120){
strokeWeight(.10);
stroke(255);
line(x1,y1,x2,y2);
}
}

void update(){ //causing bubbles to bounce back and forth at edges
if(x<0){
goingRight=true;
}
if(goingRight==true){
x=x+.5;
}

if(x>width){
goingRight=false;
}
if(goingRight==false){
x=x-.8;
}
}

void display(){ //causing bubbles to move across the screen
fill(fColor); //changes colors of dots
ellipse (x,y,diameter,diameter);
}
}

void keyPressed(){
if (key=='s'){
saveFrame("week3-####.jpg"); //saves the image in documents
}
}

bouncing balls



Spot [] sp= new Spot [100];


void setup(){
size (500,500);
smooth();
noStroke();


for(int i=0; i<50; i="0;" goingright="true;" x="xpos;" y="ypos;" diameter="dia;" fcolor="fillColor;" goingright="true;" goingright="="true){" x="x+.5;">width){
goingRight=false;
}
if(goingRight==false){
x=x-.8;
}
}

void display(){ //causing bubbles to move across the screen
fill(fColor); //changes colors of dots
ellipse (x,y,diameter,diameter);
}
}

void keyPressed(){
if (key=='s'){
saveFrame("week3-####.jpg"); //saves the image in documents
}
}

confetti



Spot [] sp= new Spot [100];


void setup(){
size (500,900);
smooth();
noStroke();

for(int i=0; i<50; i++){
sp[i] = new Spot(random(width),random(height),random(10,50), color(int(random(255)),0,0) ); //construct the object
}
}

void draw(){
background(0);
for(int i=0; i<50; i++){
sp[i].display();
}
}

class Spot{ //declaring a new class named spot
float x, y; //the x- and y-coordinate
float diameter; //diameter of the circle
color fColor;

//constructor so that the beginning spot at top doesn't need
//the excessive variables listed - it gets information from here.
Spot(float xpos, float ypos, float dia, color fillColor){
x=xpos;
y=ypos;
diameter=dia;
fColor=fillColor;
}

void display(){
fill(fColor); //changes colors of dots
ellipse (x,y,random(diameter),random(diameter));
}
}

void keyPressed(){
if (key=='s'){
saveFrame("week3-####.jpg"); //saves the image in documents
}
}


Thursday, January 31, 2008

Assignment Two






int lineX=0;
boolean switchIncrease=true;


void setup(){
size(600,300);
}

void draw(){
smooth();
fill(150,50,150,5);
rect (0,0,width, height); //leaves a "residue" when the lines moves //comment out this line to get last image

if(mousePressed == true){ //true-false input
stroke(mouseX,mouseY,.8*mouseX);
strokeWeight(4);

}
if (mousePressed == false){

stroke(255);
strokeWeight(2);

}
triangle (mouseX, mouseY, 100, 10, 50, 150); //creation of triangles
triangle (mouseX, mouseY, 125, 210, 50, 150);
triangle (mouseX, mouseY, 125, 75, 50, 150);
triangle (mouseX, mouseY, 125, 275, 50, 150);


}





void keyPressed(){
if (key=='s'){
saveFrame("homework-####.jpg"); //saves the image in documents
}
}

Friday, January 25, 2008

Assignment One


80s silk-screening at its finest

size(200,200); //changes size of workspace
background(245); //changes background color

fill(150); //applies interior color
stroke(150); //applies line color
triangle(0,0,200,200,0,200); //triangle

stroke(255); //changes line color
fill(127,200,219,50); //applies interior color + transparency
ellipse(35,0,120,120); //ellipse

strokeWeight(0); //changes line weight
stroke(255);
fill(105,75,150,150);
ellipse(190,160,160,150); //same as above

strokeWeight(3); //changes line weight
stroke(255); //changes line color
line(0,5,195,200); //line
strokeWeight(2.5);
line(0,10,190,200);
strokeWeight(2);
line(0,15,185,200);
strokeWeight(1.5);
line(0,20,180,200);
strokeWeight(1);
line(0,25,175,200);
line(0,30,170,200);
line(0,35,165,200);

stroke(162,211,152);
strokeWeight(3);
line(0,0,200,200);
strokeWeight(2.5);
line(5,0,200,195);
strokeWeight(2);
line(10,0,200,190);
strokeWeight(1.5);
line(15,0,200,185);
strokeWeight(1);
line(20,0,200,180);
line(25,0,200,175);
line(30,0,200,170);
line(35,0,200,165);

stroke(202,200,193); //changes line color
fill(202,200,193,150); //applies interior color + transparency
rect(0,160,200,10); //rectangle
rect(0,175,200,15); //rectangle
rect(0,10,200,5); //rectangle