Digital Bauhaus Vorkurs/Projekte/Kleckse/TassenCODE: Difference between revisions

From Medien Wiki
(Created page with "float a = 100; float b = 100; float angle1 = 0.0; float segLength = 50; float x = width/2; float y = height/2; float s = 10; float c = 255; float klexkomplex = 5; float dichte...")
 
mNo edit summary
Line 1: Line 1:
<source lang="Java">
float a  = 100;
float a  = 100;
float b  = 100;
float b  = 100;
Line 75: Line 77:
   }
   }
}
}
</source>

Revision as of 15:52, 17 April 2011

float a  = 100;
float b  = 100;
float angle1 = 0.0;
float segLength = 50;

float x = width/2;
float y = height/2;
float s = 10;
float c = 255;
float klexkomplex = 5;
float dichteMin = -10;
float dichteMax = 10;



void setup () {

  size(700,700);
  smooth();
  background(0);
  noStroke(); 
  reset();

  //ellipse(x,y,s,s);fff

}

void reset() {
  
  background (240, 128, 128, 200);
  x = (float)random(width);
  y = (float)random(height);
  s = (float)random(255);
  c = (float)random(238);
  
}  
  
void draw () {
  
//  if(klexkomplex > (width/15) ) {
//   return;
 //}

  //ellipse(x,y,s,s);

  int i;
  for(i=0; i<klexkomplex; i=i+1) {
    x = x + (float)random(dichteMin,dichteMax);
    y = y + (float)random(dichteMin,dichteMax);
    c = (float)random(255);
    s = (float)random(dichteMin,dichteMax);
    fill(0);
  }
  
  
  float dx = mouseX - x;
  float dy = mouseY - y;
  angle1 = atan2(dy, dx);  
  x = mouseX - (cos(angle1) * segLength);
  y = mouseY - (sin(angle1) * segLength);
  
  
  ellipse(x,y,s,s);
}




void keyPressed() {
  if ((key== 'r')) {
    reset(); 
  }
  if (key== 'h') {
    exit();
  }
}