Kreativ-programmering Opgave 5

From CCT - Vidensdeling
Jump to: navigation, search

Løsningsforslag til opgave 5 fra forløbet om kreativ programmering:


void setup(){

 size(600,300);  
 
 drawLines();

}

void draw(){

}

void drawLines(){

 background(0);  
 stroke(#0000AA);
 for(int i = 0; i < 20; i++){
   line(0,i*15,width,i*15);       
 }
 for(int i = 0; i < 40; i++){
   line(i*15,0,i*15,height);       
 }
 stroke(255);
 
 for(int i = 0; i < 24; i++){
   
   line(20*15,10*15,15*(int)random(40), 15*(int)random(20));
 }
 for(int i = 0; i < 12; i++){
   line(20*15,0,15*(int)random(40), 15*(int)random(20));
   line(0,10*15,15*(int)random(40), 15*(int)random(20));
   line(20*15,20*15,15*(int)random(40), 15*(int)random(20));
   line(40*15,10*15,15*(int)random(40), 15*(int)random(20));
   line(0,0,15*(int)random(40), 15*(int)random(20));
   line(40*15,0,15*(int)random(40), 15*(int)random(20));
   line(0,20*15,15*(int)random(40), 15*(int)random(20));
   line(40*15,20*15,15*(int)random(40), 15*(int)random(20));
 }

}

void keyPressed(){

 drawLines();  

}