De driehoeken in de draaipunten met h1 = 2*n
Driehoek met 90 graden hoek "Drieh_nh90". terug naar de inleiding
argumenten van de constructor:
1) n = basis, 2) h1 = hoogte, 3) lr = 1 schuine zijde --> rechts, lr = 0 schuine zijde --> links, 4) draaipunten 0 t/m6, 5) x positie, 6) y positie, 7) hoek, 8) kleur
class Drieh_nh90 extends Vormen {
Drieh_nh90(float n_, float h1_, int lr_, int d_, float x_, float y_, float hoek_, color c1_) {
super();
n = n_;
h1 = h1_;
lr = lr_;
d = d_;
x = x_;
y = y_;
hoek = hoek_;
c1 = c1_;
}
void display() {
fill(c1);
pushMatrix();
translate(x, y);
rotate(radians(hoek));
beginShape();
if (d == 0 && lr == 0) {vertex(-n/4,h1/4);vertex(-n/4,-3*h1/4);vertex(3*n/4,h1/4);}
if (d == 1 && lr == 0) {vertex(0,0);vertex(0,-h1);vertex(n,0);}
if (d == 2 && lr == 0) {vertex(0,h1/2);vertex(0,-h1/2);vertex(n,h1/2);}
if (d == 3 && lr == 0) {vertex(0,h1);vertex(0,0);vertex(n,h1);}
if (d == 4 && lr == 0) {vertex(-n/2,h1/2);vertex(-n/2,-h1/2);vertex(n/2,h1/2);}
if (d == 5 && lr == 0) {vertex(-n,0);vertex(-n,-h1);vertex(0,0);}
if (d == 6 && lr == 0) {vertex(-n/2,0);vertex(-n/2,-h1);vertex(n/2,0);}
if (d == 0 && lr == 1) {vertex(-3*n/4,h1/4);vertex(n/4,-3*h1/4);vertex(n/4,h1/4);}
if (d == 1 && lr == 1) {vertex(0,0);vertex(n,-h1);vertex(n,0);}
if (d == 2 && lr == 1) {vertex(-n/2,h1/2);vertex(n/2,-h1/2);vertex(n/2,h1/2);}
if (d == 3 && lr == 1) {vertex(-n,h1);vertex(0,0);vertex(0,h1);}
if (d == 4 && lr == 1) {vertex(-n,h1/2);vertex(0,-h1/2);vertex(0,h1/2);}
if (d == 5 && lr == 1) {vertex(-n,0);vertex(0,-h1);vertex(0,0);}
if (d == 6 && lr == 1) {vertex(-n/2,0);vertex(n/2,-h1);vertex(n/2,0);}
endShape(CLOSE);
popMatrix();
}
}