header I

 

pentomino "I"                            bekijk de rotaties van pentomino "I"                      terug naar de inleiding 

 

 

class I extends Vormen { 
I(float n_, int d_, float x_, float y_, float hoek_, color c1_) {  
 super();  
 n = n_;  
 x = x_;  
 y = y_;  
 hoek = hoek_;  
 c1 = c1_;  
 d = d_;  
 } 
void display() {  
 fill(c1);  
 // noStroke();  
 pushMatrix();  
 translate(x, y);  
 rotate(radians(hoek));  
 beginShape(); 
 if (d == 0) {vertex(-n/2,2.5*n);vertex(-n/2,-2.5*n);vertex(n/2,-2.5*n);vertex(n/2,2.5*n);}  
 if (d == 1) {vertex(0,0); vertex(0,-5*n); vertex(n,-5*n); vertex(n,0);}  
 if (d == 2) {vertex(0,5*n); vertex(0,0); vertex(n,0); vertex(n,5*n);}  
 if (d == 3) {vertex(-n,5*n); vertex(-n,0); vertex(0,0); vertex(0,5*n);}  
 if (d == 4) {vertex(-n,0); vertex(-n,-5*n); vertex(0,-5*n); vertex(0,0);}  
 endShape(CLOSE);  
 popMatrix();  
 }  
}
 
voorbeeld met "I"
 
 

Vormen vorm1; 
Vormen vorm2; 
Vormen vorm3; 
Vormen vorm0; 
 
void setup() { 
  size(600, 600); 
 // fullScreen(); 
  float x = width/2; 
  float y = height/2; 
  float n = height/15; 
  vorm0 = new I(n, 4, x-n, y-n, 0, color(200, 255, 0, 50)); 
  vorm1 = new I(n, 1, x+n, y-n, 0, color(200, 0, 0, 50)); 
  vorm2 = new I(n, 3, x-n, y+n, 0, color(0, 0, 255, 50)); 
  vorm3 = new I(n, 2, x+n, y+n, 0, color(0, 100, 0, 50)); 
} 
 
void draw() { 
  background(#E6FBFF); 
  //assenstelsel 
  stroke(255, 0, 0); 
  line (width/2, 0, width/2, height); 
  line(0, height/2, width, height/2); 
  stroke(0);  
  vorm0.display(); 
  vorm1.display(); 
  vorm2.display(); 
  vorm3.display(); 
  
  vorm0.dpRotLi(vorm0); 
  vorm1.dpRotRe(vorm1); 
  vorm2.dpRotRe(vorm2); 
  vorm3.dpRotLi(vorm3); 
} 
void keyPressed() {        
  if (key == 's') {       
    noLoop();   
  }      
   
  if (key == 'r') {          
    loop();   
  }     
}