Tangram "Haas" 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[];
void setup() {
// fullScreen();
size(500,800);
int n = height/12;
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, 5, x, y, -90, color(255, 0, 0));
vorm[1] = new Drieh_an(n*2, 5, x-a, y+a, 225, color(0, 255, 0));
vorm[2] = new Rechthoek(n,n,1, x, y, 0, color(0, 244, 255));
vorm[3] = new Drieh_an(n, 1, x, y, 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, 1, x, y-n, -90, color(0, 0, 255));
vorm[6] = new Paral(n,n, 1, 1, x+n, y-n, -20, 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);
}
Tangram "renner" De schets maakt gebruik van de superclass: "Vormen"
en de subclasses: "Drieh_an" , "Paral" en "Rechthoek".
Vormen vorm [];
void setup() {
// fullScreen();
size(500,500);
int n = height/10;
float a = sqrt(2*n*n); //runner
float x = width/2;
float y = height/2;
vorm = new Vormen[7];
vorm[0] = new Rechthoek(n,n,1, x-a/4, y-2*n, -30, color(0, 244, 255));
vorm[1] = new Drieh_an(n, 1, x-n, y+n*5/2, 90, color(255, 255, 0));
vorm[2] = new Drieh_an(n, 6, x+n*4/3, y+n*4/3, 45, color(255, 255, 0));
vorm[3] = new Drieh_an(a, 5, x-n, y+n*5/6, 270, color(0, 0, 255));
vorm[4] = new Drieh_an(n*2, 6, x, y, 225, color(255, 0, 0));
vorm[5] = new Drieh_an(n*2, 5, x, y, 45, color(0, 255, 0));
vorm[6] = new Paral(n,n,1, 1, x, y-n*2, 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);
}