header rechth

                                                             terug naar de inleiding

 Class    "Rechthoek"             Deze class heeft als extra argumenten in de constructor:   sw = lijndikte , strokeWeight() en sc = lijnkleur, stroke()

zie ook de class "Rechthoek" in processing

 

//argumenten van de constructor 
//1) breedte, 2) hoogte, 3) draaipunt, 4) x positie, 5) y positie, 
//6) hoek     7) vormkleur,    8) lijndikte, 9) lijnkleur 
class Rechthoek extends Vormen { 
  //          1  2   3  4  5   6    7  8   9 
  constructor(n, h1, d, x, y, hoek, c, sw, sc) { 
 
    super(x, y, hoek); 
    this.x  = x; this.y  = y;  this.hoek = hoek; 
    this.n  = n; this.h1 = h1; this.d = d; 
    this.c  = c; this.sw = sw; this.sc = sc; 
} 
 
display() { 
  push(); 
  fill(this.c); 
  strokeWeight(this.sw); 
  stroke(this.sc); 
  translate(this.x,this.y); 
  rotate(radians(this.hoek)); 
  beginShape(); 
  if (this.d == 1) {vertex(0, 0);         vertex(0, -this.h1);  vertex(this.n, -this.h1);   vertex(this.n, 0);} 
  if (this.d == 2) {vertex(0, this.h1/2); vertex(0, -this.h1/2);vertex(this.n, -this.h1/2); vertex(this.n, this.h1/2);} 
  if (this.d == 3) {vertex(0, this.h1);   vertex(0, 0);         vertex(this.n, 0);          vertex(this.n, this.h1); } 
  if (this.d == 4) {vertex(-this.n/2, this.h1);  vertex(-this.n/2, 0);         vertex(this.n/2, 0);         vertex(this.n/2, this.h1);} 
  if (this.d == 5) {vertex(-this.n, this.h1);    vertex(-this.n, 0);           vertex(0, 0);                vertex(0, this.h1);} 
  if (this.d == 6) {vertex(-this.n, this.h1/2);  vertex(-this.n,-this.h1/2);   vertex(0, -this.h1/2);       vertex(0, this.h1/2);} 
  if (this.d == 7) {vertex(-this.n, 0);          vertex(-this.n, -this.h1);    vertex(0, -this.h1);         vertex(0, 0);} 
  if (this.d == 8) {vertex(-this.n/2, 0);        vertex(-this.n/2, -this.h1);  vertex(this.n/2, -this.h1);  vertex(this.n/2, 0);} 
  if (this.d == 0) {vertex(-this.n/2, this.h1/2);vertex(-this.n/2, -this.h1/2);vertex(this.n/2, -this.h1/2);vertex(this.n/2, this.h1/2);} 
  endShape(CLOSE); 
  pop(); 
 } 
}