Code voor het maken van de vorm header terug naar de inleiding
Als voorbeeld is gekozen voor de header van de "Paral" class.
Vormen [] vorm;
Vormen [] dp_num;
Ruitjes ruitjespap;
void setup() {
size(1500,300);
float x = width/2;
float y = height/2;
float n = height/6;
int cl = color(0); //cijferkleur
int klvorm = color(#E8AC3D,150); //vormkleur
float h = n; //hoogte van de vorm
float l = n; //lengte van de vorm
float tl = n/3;// grootte van de getallen bij de draaipunten
vorm = new Vormen[18];
dp_num = new Vormen[20];
ruitjespap = new Ruitjes(x,y,n);
dp_num[0] = new Text("0", tl, 1, x-0.8*n, y-1.5*n,0, cl);
vorm[0] = new Paral(h,l, 1, 0, x, y-1.5*n,0, klvorm);
dp_num[1] = new Text("1", tl, 1, x-13*n, y-1.5*n,0, cl);
vorm[1] = new Paral(h,l, 1, 1, x-13*n, y-n, 0, klvorm);
dp_num[2] = new Text("2", tl, 1, x-9.8*n, y-1.5*n,0, cl);
vorm[2] = new Paral(h,l ,1, 2, x-9.5*n, y-1.5*n,0, klvorm);
dp_num[3] = new Text("3", tl, 1, x-6.8*n, y-1.5*n,0, cl);
vorm[3] = new Paral(h,l, 1, 3, x-6*n, y-2*n, 0, klvorm);
dp_num[4] = new Text("4", tl, 1, x-2.5*n, y-1.2*n,0, cl);
vorm[4] = new Paral (h,l,1, 4, x-2.5*n, y-2*n, 0, klvorm);
dp_num[5] = new Text("5", tl, 1, x+3.5*n, y-1.2*n,0, cl);
vorm[5] = new Paral(h,l, 1, 5, x+4*n, y-2*n, 0, klvorm);
dp_num[6] = new Text("6", tl, 1, x+6.5*n, y-1.1*n,0, cl);
vorm[6] = new Paral(h,l, 1, 6, x+6.5*n, y-1.5*n,0, klvorm);
dp_num[7] = new Text("7", tl, 1, x+9.5*n, y-1.1*n,0, cl);
vorm[7] = new Paral(h,l, 1, 7, x+9*n, y-n, 0, klvorm);
dp_num[8] = new Text("8", tl, 1, x+12.5*n,y-1.1*n,0, cl);
vorm[8] = new Paral(h,l, 1, 8, x+11.5*n,y-n, 0, klvorm);
dp_num[9] = new Text("0", tl, 1, x-0.8*n, y+1.9*n,0, cl);
vorm[9] = new Paral(h,l, 0, 0, x, y+1.5*n,0, klvorm);
dp_num[10] = new Text("1", tl, 1, x-12.8*n,y+1.8*n,0, cl);
vorm[10] = new Paral(h,l, 0, 1, x-12*n, y+2*n, 0, klvorm);
dp_num[11] = new Text("2", tl, 1, x-9.8*n, y+1.8*n,0, cl);
vorm[11] = new Paral(h,l, 0, 2, x-9.5*n, y+1.5*n,0, klvorm);
dp_num[12] = new Text("3", tl, 1, x-6.8*n, y+1.8*n,0, cl);
vorm[12] = new Paral(h,l, 0, 3, x-7*n, y+n, 0, klvorm);
dp_num[13] = new Text("4", tl, 1, x-3.8*n, y+1.8*n,0, cl);
vorm[13] = new Paral(h,l, 0, 4, x-3.5*n, y+n, 0, klvorm);
dp_num[14] = new Text("5", tl, 1, x+3.5*n, y+1.5*n,0, cl);
vorm[14] = new Paral(h,l, 0, 5, x+3*n, y+n, 0, klvorm);
dp_num[15] = new Text("6", tl, 1, x+6.8*n, y+1.5*n,0, cl);
vorm[15] = new Paral(h,l, 0, 6, x+6.5*n, y+1.5*n,0, klvorm);
dp_num[16] = new Text("7", tl, 1, x+9.5*n, y+1.5*n,0, cl);
vorm[16] = new Paral(h,l,0, 7, x+10*n, y+2*n, 0, klvorm);
dp_num[17] = new Text("8",tl, 1, x+12.5*n, y+1.5*n,0, cl);
vorm[17] = new Paral(h,l,0, 8, x+12.5*n, y+2*n, 0, klvorm);
dp_num[18] = new Text("lr = 0", tl, 1, x-14.5*n,y+1.5*n, 0,color(cl));
dp_num[19] = new Text("lr = 1", tl, 1, x-14.5*n,y-1.5*n, 0,color(cl));
}
void draw() {
background(#E6FBFF);
ruitjespap.display();
strokeWeight(2);
//de vormen
for (int i = 0; i< 18; i++)
{
vorm[i].display();
}
//getallen bij de draaipunten, dit is een methode in de class "Text"
for (int i = 0; i< 20; i++)
{
dp_num[i].display();
}
//de draaipunten van de vormen. De methode staat in de class "Vormen"
for (int i = 0; i< 18; i++)
{
vorm[i].dpAan();
}
}