classes "Trap_3nan" , "Trap_2nn" , "Ruit" , "Vlieger"
class "Trap_3nan" in p5.js terug naar de inleiding
zie ook de class "Trap_3nan in processing
class Trap_3nan extends Vormen {
constructor(n, d, x, y, hoek, c, sw, sc) {
super(x,y,hoek);
this.x = x; this.y = y; this.hoek = hoek;
this.n = n; this.d = d; this.c = c; this.sw = sw; this.sc = sc;
}
display() {
fill(this.c);
fill(this.c);
strokeWeight(this.sw);
let n = this.n; let d = this.d
push();
translate(this.x, this.y);
rotate(radians(this.hoek));
beginShape();
if (d == 0) {vertex(-1.5*n, n/2); vertex(-n/2, -n/2); vertex(n/2, -n/2); vertex(1.5*n, n/2);}
if (d == 1) {vertex(0, 0); vertex(n, -n); vertex(2*n, -n); vertex(3*n, 0);}
if (d == 2) {vertex(-n/2, n/2);vertex(n/2, -n/2); vertex(1.5*n, -n/2); vertex(2.5*n, n/2);}
if (d == 3) {vertex(-n, n); vertex(0, 0); vertex(n, 0); vertex(2*n, n);}
if (d == 4) {vertex(-1.5*n, n); vertex(-n/2, 0); vertex(n/2, 0); vertex(1.5*n, n);}
if (d == 5) {vertex(-2*n, n); vertex(-n, 0); vertex(0, 0); vertex(n, n);}
if (d == 6) {vertex(-2.5*n, n/2); vertex(-1.5*n, -n/2); vertex(-n/2, -n/2);vertex(n/2, n/2);}
if (d == 7) {vertex(-3*n, 0); vertex(-2*n, -n); vertex(-n, -n); vertex(0, 0);}
if (d == 8) {vertex(-1.5*n, 0); vertex(-n/2, -n); vertex(n/2, -n); vertex(1.5*n, 0);}
endShape(CLOSE);
pop();
}
}
class "Trap_2nn"
class Trap_2nn extends Vormen {
constructor(n, d, x, y, hoek, c, sw, sc) {
super(x,y,hoek);
this.n = n; this.x = x; this.y = y; this.hoek = hoek;
this.d = d; this.c = c; this.sw = sw; this.sc = sc;
}
display() {
fill(this.c);
strokeWeight(this.sw);
stroke(this.sc);
let d = this.d; let n = this.n;
push();
translate(this.x, this.y);
rotate(radians(this.hoek));
beginShape();
let hn = sqrt(3*n*n/4);
if (d == 0) {vertex(-n, hn/2); vertex(-n/2, -hn/2); vertex(n/2, -hn/2); vertex(n, hn/2);}
if (d == 1) {vertex(0, 0); vertex(n/2, -hn); vertex(3*n/2, -hn); vertex(2*n, 0);}
if (d == 2) {vertex(-n/4, hn/2);vertex(n/4, -hn/2); vertex(5*n/4, -hn/2); vertex(7*n/4, hn/2);}
if (d == 3) {vertex(-n/2, hn); vertex(0, 0); vertex(n, 0); vertex(3*n/2, hn);}
if (d == 4) {vertex(-n, hn); vertex(-n/2, 0); vertex(n/2, 0); vertex(n, hn);}
if (d == 5) {vertex(-3*n/2, hn); vertex(-n, 0); vertex(0, 0); vertex(n/2, hn);}
if (d == 6) {vertex(-7*n/4, hn/2); vertex(-5*n/4, -hn/2); vertex(-n/4, -hn/2);vertex(n/4, hn/2);}
if (d == 7) {vertex(-2*n, 0); vertex(-3*n/2, -hn); vertex(-n/2, -hn); vertex(0, 0);}
if (d == 8) {vertex(-n, 0); vertex(-n/2, -hn); vertex(n/2, -hn); vertex(n, 0);}
endShape(CLOSE);
pop();
}
}
class "Ruit"

class Ruit extends Vormen {
constructor(n, d, x, y, hoek, c, sw, sc) {
super(x, y, hoek)
this.x = x; this.y = y; this.hoek = hoek;
this.n = n; this.d = d; this.c = c;
this.sw = sw; this.sc = sc
}
display() {
fill(this.c);
let d = this.d; let n = this.n;
strokeWeight(this.sw);
stroke(this.sc);
push();
translate(this.x, this.y);
rotate(radians(this.hoek));
beginShape();
let hn = sqrt(3*n*n/4);
if (d == 0) {vertex(0, hn); vertex(-n/2, 0); vertex(0, -hn); vertex(n/2, 0);}
if (d == 1) {vertex(0, 0); vertex(-n/2, -hn); vertex(0, -2*hn); vertex(n/2,-hn);}
if (d == 2) {vertex(n/4, hn/2);vertex(-n/4, -hn/2); vertex(n/4, -3*hn/2); vertex(3*n/4, -hn/2);}
if (d == 3) {vertex(n/2, hn); vertex(0, 0); vertex(n/2, -hn); vertex(n, 0);}
if (d == 4) {vertex(n/4, 3*hn/2); vertex(-n/4, hn/2); vertex(n/4, -hn/2); vertex(3*n/4, hn/2);}
if (d == 5) {vertex(0, 2*hn); vertex(-n/2, hn); vertex(0, 0); vertex(n/2, hn);}
if (d == 6) {vertex(-n/4, 3*hn/2); vertex(-3*n/4, hn/2); vertex(-n/4, -hn/2);vertex(n/4, hn/2);}
if (d == 7) {vertex(-n/2, hn); vertex(-n, 0); vertex(-n/2, -hn); vertex(0, 0);}
if (d == 8) {vertex(-n/4, hn/2); vertex(-3*n/4, -hn/2); vertex(-n/4, -3*hn/2); vertex(n/4, -hn/2);}
endShape(CLOSE);
pop();
}
}
class "Vlieger"
zie ook de class "Vlieger" in processing
constructor argumenten:
1) n = lengte korte diagonaal, 2) h1 = lengte top naar korte diagonaal, 3) h2 = lengte punt naar korte diagonaal
4) d = draaipunt, 5) x positie, 6) y positie, 7) hoek, 8) kleur, 9) lijndikte sw, 10) lijnkleur sc
// constructor argumenten:
// 1) n = lengte korte diagonaal, 2) h1 = lengte top naar korte diagonaal, 3) h2 = lengte punt naar korte diagonaal
// 4) d = draaipunt, 5) x positie, 6) y positie, 7) hoek, 8) kleur, 9) lijndikte sw, 10) Lijnkleu sc
class Vlieger extends Vormen {
// 1 2 3 4 5 6 7 8 9 10
constructor(n, h1, h2, 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.h2 = h2;
this.d = d; this.c = c; this.sw = sw; this.sc = sc;
}
display() {
let n = this.n; let h1= this.h1; let h2 = this.h2; let d = this.d;
fill(this.c);
strokeWeight(this.sw);
stroke(this.sc);
push();
translate(this.x, this.y);
rotate(radians(this.hoek));
beginShape();
if (d == 0) {vertex(0, h2);vertex(-n/2, 0);vertex(0, -h1);vertex(n/2, 0);}
if (d == 1) {vertex(0, 0);vertex(-n/2, -h2);vertex(0, -(h1+h2));vertex(n/2, -h2);}
if (d == 2) {vertex(n/4, h2/2); vertex(-n/4, -h2/2);vertex(n/4, -(h2/2+h1)); vertex(3*n/4, -h2/2);}
if (d == 3) {vertex(n/2, h2);vertex(0, 0);vertex(n/2, -h1); vertex(n, 0);}
if (d == 4) {vertex(n/4, h2+h1/2);vertex(-n/4, h1/2);vertex(n/4, -h1/2); vertex(3*n/4, h1/2);}
if (d == 5) {vertex(0, h1+h2);vertex(-n/2, h1);vertex(0, 0);vertex(n/2, h1);}
if (d == 6) {vertex(-n/4, h1/2+h2);vertex(-3*n/4, h1/2);vertex(-n/4, -h1/2); vertex(n/4, h1/2);}
if (d == 7) {vertex(-n/2, h2);vertex(-n, 0);vertex(-n/2, -h1);vertex(0, 0);}
if (d == 8) {vertex(-n/4, h2/2);vertex(-3*n/4, -h2/2);vertex(-n/4, -(h2/2+h1)); vertex(n/4, -h2/2);}
endShape(CLOSE);
pop();
}