Digital Bauhaus Vorkurs/Projekte/Linie/Programmierung5

From Medien Wiki
< Digital Bauhaus Vorkurs‎ | Projekte‎ | Linie
Revision as of 14:13, 22 March 2011 by Feivel (talk | contribs) (Created page with " == Linien mit begrenzter Länge aus dem Mittelpunkt == <source lang="Java" highlight="14"> boolean aON=false; boolean bON=false; int x2; int y2; float distance = 201; void s...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Linien mit begrenzter Länge aus dem Mittelpunkt

<source lang="Java" highlight="14">

boolean aON=false; boolean bON=false;

int x2; int y2; float distance = 201;

void setup() {

 size(500,500);
 background(255); 
 smooth();

}

void draw() {

 if(aON) {
   drawLine1();
 }
 if(bON) {
   background(255);
 }
 if(aON = true) {
   aON = false;
 }
 if(bON = true) {
   bON = false;
 }

}

void keyTyped() {

 if(keyPressed) {
   if (key == '1') {
     aON = true;
   } 
   else {
     aON = false;
   }
 }
 if(keyPressed) {
   if (key == '2') {
     bON = true;
   } 
   else {
     bON = false;
   }
 }

}

void drawLine1() {

 while(distance > 200) {
   x2=(int)random(500);
   y2=(int)random(500);
   distance=dist(250,250,x2,y2);
 }
 stroke(0);
 line(250,250,x2,y2);
 distance = 201;

}