Digital Bauhaus Vorkurs/Projekte/Linie/Programmierung1

From Medien Wiki
< Digital Bauhaus Vorkurs‎ | Projekte‎ | Linie
Revision as of 14:08, 22 March 2011 by Feivel (talk | contribs) (Created page with "== Linien zufälliger Länge aus den vier Ecken == <source lang="Java" highlight="14"> boolean aON=false; boolean bON=false; boolean cON=false; boolean dON=false; boolean eON=f...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Linien zufälliger Länge aus den vier Ecken

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

boolean aON=false; boolean bON=false; boolean cON=false; boolean dON=false; boolean eON=false;


void setup() {

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

}

void draw() {

 if(aON) {
   drawLine1();
 }
 if(bON) {
   drawLine2();
 }
 if(cON) {
   drawLine3();
 }
 if(dON) {
   drawLine4();
 }
 if(eON) {
   background(255);
 }    
 if(aON = true) {
   aON = false;
 }
 if(bON = true) {
   bON = false;
 }
 if(cON = true) {
   cON = false;
 }
 if(dON = true) {
   dON = false;
 }
 if(eON = true) {
   eON = false;
 }

}

void keyTyped() {

 if(keyPressed) {
   if (key == '1') {
     aON = true;
   } else {
     aON = false;
   }
 }
 if(keyPressed) {
   if (key == '2') {
     bON = true;
   } else {
     bON = false;
   }
 }
 if(keyPressed) {
   if (key == '3') {
     cON = true;
   } else {
     cON = false;
   }
 }
 if(keyPressed) {
   if (key == '4') {
     dON = true;
   } else {
     dON = false;
   }
 }
 if(keyPressed) {
   if (key == '5') {
     eON = true;
   } else {
     eON = false;
   }
 }

}

void drawLine1() {

 int x2=(int)random(500);
 int y2=(int)random(500);
 stroke(0);
 line(0,0,x2,y2);

} void drawLine2() {

 int x2=(int)random(500);
 int y2=(int)random(500);
 stroke(0);
 line(500,0,x2,y2);

} void drawLine3() {

 int x2=(int)random(500);
 int y2=(int)random(500);
 stroke(0);
 line(500,500,x2,y2);

} void drawLine4() {

 int x2=(int)random(500);
 int y2=(int)random(500);
 stroke(0);
 line(0,500,x2,y2);

}