Tangram "Gans" De schets maakt gebruik van de superclass: "Vormen" terug naar de inleiding
De 3 tangram rechhoekige driehoeken worden samengesteld met Drieh_an, zie de tabel:
Het eerste argument in de constructor is de lengte van de schuine zijde.
a = sqrt(2*n*n);
driehoek basis |
schuine zijde
|
hoogte | |||
klein, basis = a | n | a/2 | |||
middel, basis = 2*n | a | n | |||
groot, basis = 2*a | 2*n | a |
Vormen vorm[];
Ruitjes ruitjespap;
void setup() {
// fullScreen();
size(500,800);
int n = height/12;
float a = sqrt(2*n*n);
float x = width/2;
float y = height/2;
//gans
vorm = new Vormen[7];
ruitjespap = new Ruitjes(n,x,y);
vorm[0] = new Drieh_an(n*2, 2, x, y, -135, color(255, 255, 0));
vorm[1] = new Drieh_an(n*2, 3, x, y, -45, color(0, 255, 0));
vorm[2] = new Rechthoek(n,n,5, x, y, 0, color(0, 244, 255));
vorm[3] = new Drieh_an(n, 6, x, y+2*n, 135, color(255, 255, 0));
vorm[4] = new Drieh_an(n, 6, x-n, y+n, 180, color(255, 255, 0));
vorm[5] = new Drieh_an(a, 6, x-n, y-(2*n+a), 45, color(0, 0, 255));
vorm[6] = new Paral(n,n,0, 1, x-n, y-2*n, 45, color(255, 0, 255));
}
void draw() {
background(#E6FBFF);
stroke(0);
ruitjespap.display();
for (int i = 0; i <7; i++)
{
vorm[i].display();
}
//assenstelsel
stroke(255, 0, 0);
line(width/2,0, width/2, height);
line(0, height/2, width, height/2);
}
Tangram "Kat" De schets maakt gebruik van de superclass: "Vormen"
Vormen vorm[];
void setup() {
size(500,500);
int n = height/9;
float a = sqrt(2*n*n);
float x = width/2;
float y = height/2;
vorm = new Vormen[7];
vorm[0] = new Drieh_an(n*2, 1, x, y, 90, color(255, 0, 0));
vorm[1] = new Drieh_an(n*2, 1, x+a, y+a, 135, color(0, 255, 0));
vorm[2] = new Rechthoek(n,n,1, x, y, -45, color(0, 244, 255));
vorm[3] = new Drieh_an(n, 3, x, y-a, -90, color(255, 255, 0));
vorm[4] = new Drieh_an(n, 3, x, y-a, +90, color(255, 255, 0));
vorm[5] = new Drieh_an(a, 5, x, y, 270, color(0, 0, 255));
vorm[6] = new Paral(n,2*n,0, 3, x+a, y+a+2*n,-90, color(255, 0, 255));
}
void draw() {
background(#E6FBFF);
stroke(0);
for (int i = 0; i < 7; i++)
{
vorm[i].display();
}
//assenstelsel
stroke(255, 0, 0);
line(width/2,0, width/2, height);
line(0, height/2, width, height/2);
}