header hoek n2n
 
 
hoek   "Hoek_n2n".               ga naar de animatie met de roterende hoeken                 terug naar de inleiding
 
 

class Hoek_n2n extends Vormen { 
 
  Hoek_n2n(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(); 
    float a; 
    a =  sqrt(2*n*n); 
    if (d == 0) {vertex(-a/2,a/2);vertex(-a,0);vertex(0,-a);vertex(a,0);vertex(a/2,a/2);vertex(0,0);} 
    if (d == 1) {vertex(0,0);vertex(-a/2,-a/2);vertex(a/2,-3*a/2);vertex(3*a/2, -a/2);vertex(a, 0);vertex(a/2, -a/2);}         
    if (d == 2) {vertex(a/2,a/2);vertex(0, 0);vertex(a,-a);vertex(2*a,0);vertex(3*a/2,a/2);vertex(a,0);}         
    if (d == 3) {vertex(0,a);vertex(-a/2, a/2);vertex(a/2,-a/2);vertex(3*a/2,a/2);vertex(a,a);vertex(a/2,a/2);}       
    if (d == 4) {vertex(-a/2,3*a/2);vertex(-a,a);vertex(0,0);vertex(a,a);vertex(a/2,3*a/2);vertex(0,a);}          
    if (d == 5) {vertex(-a,a);vertex(-3*a/2,a/2);vertex(-a/2,-a/2);vertex(a/2,a/2);vertex(0,a);vertex(-a/2,a/2);}         
    if (d == 6) {vertex(-3*a/2,a/2);vertex(-2*a,0);vertex(-a,-a);vertex(0,0);vertex(-a/2,a/2);vertex(-a,0);}       
    if (d == 7) {vertex(-a,0); vertex(-3*a/2,-a/2);vertex(-a/2,-3*a/2); vertex(a/2,-a/2);vertex(0,0);vertex(-a/2,-a/2);}     
    if (d == 8) {vertex(-a/2,a/2);vertex(-a,0);vertex(0,-a);vertex(a,0);vertex(a/2,a/2);vertex(0,0);} 
     endShape(CLOSE); 
    popMatrix(); 
  } 
} 


 
vier roterende hoeken
bekijk  de roterende hoeken
 
 

Vormen [] vorm; 
 
void setup() {  
  size(780, 560);  
  //fullScreen();  
  float x = width/2;  
  float y = height/2;  
  float n = height/8;  
  float a = sqrt(2*n*n);  
  vorm = new Vormen[6]; 
  vorm[0] = new Hoek_n2n(n, 2, x, y, 0, color(255, 0, 0, 100)); 
  vorm[1] = new Hoek_n2n(n, 3, x+a, y, -90, color(0, 0, 255, 100)); 
  vorm[2] = new Hoek_n2n(n, 4, x, y-a, 0, color(0, 255, 100, 100)); 
  vorm[3] = new Hoek_n2n(n, 5, x-a, y, 90, color(0, 255, 0, 100)); 
  vorm[4] = new Hoek_n2n(n, 6, x, y, 0, color(255, 0, 200, 100)); 
  vorm[5] = new Hoek_n2n(n, 8, x, y+a, 0, color(150, 100, 50, 100)); 
}  
 
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);   
 
  for (int i = 0; i < 6; i++) 
  { 
    vorm[i].display(); 
  }  
  vorm[1].dpRotLi(vorm[1]);   
  vorm[3].dpRotRe(vorm[3]);   
  vorm[4].dpRotLi(vorm[4]); 
  vorm[0].dpRotRe(vorm[0]); 
}  
 
void keyPressed() {     
  if (key == 's') {    
    noLoop(); 
  }   
 
  if (key == 'r') {       
    loop(); 
  } 
}