vier gouden driehoeken en twee vijfhoeken Vhoek_n5 in p5.js. terug naar de inleiding
Met de "s" toets stoppen de rotaties met iedere andere toets starten de rotaties weer.
de schets maakt gebruik van de p5.js classes "Drieh_9g_kg" , "Vhoek_n5" en de p5.js superclass "Vormen"
let vorm = [];
function setup() {
buttonR = createButton('reset');
buttonR.position(20,30);buttonR.style('width','50px');
buttonR.mouseClicked(buttonRAction);
button9 = createButton('9');
button9.position(20,60);button9.style('width','30px');
button9.mouseClicked(button9Action);
button8 = createButton('8');
button8.position(20,90);button8.style('width','30px');
button8.mouseClicked(button8Action);
button7 = createButton('7');
button7.position(20,120);button7.style('width','30px');
button7.mouseClicked(button7Action);
buttonD = createButton('download');
buttonD.position(20,150);buttonD.style('width','80px');
buttonD.mouseClicked(buttonDAction);
createCanvas(windowWidth,windowHeight);
let x = width/2; let y = height/2; let n = height/4;
let sw = n/100; let scR = color(255,0,0); let scZ = color(0);
let c = color(0,0,0,0);
vorm[0] = new Drieh_9g_kg(n, 1, 9, x, y, 0, sw, scR);
vorm[1] = new Drieh_9g_kg(n, 0, 9 ,x, y, 0, sw, scZ);
vorm[2] = new Drieh_9g_kg(n, 1, 9, x, y, 180, sw, scR);
vorm[3] = new Drieh_9g_kg(n, 0, 9 ,x, y, 180, sw, scZ);
vorm[4] = new Vhoek_n5(n, 3, x, y, 0, c, sw, scZ);
vorm[5] = new Vhoek_n5(n, 3, x, y, 180,c, sw, scZ);
}
function draw() {
clear()
background('rgba(255,255,255, 0)');
for (let i = 0; i < 6; i++){vorm[i].display()}
if (key == 's' || key == 'S') { }
else {
vorm[0].dpRotLi(vorm[0]); vorm[1].dpRotRe(vorm[1]);
vorm[2].dpRotLi(vorm[2]); vorm[3].dpRotRe(vorm[3]);
}
}
function buttonRAction(){setup()}
function button9Action()
{for (let i=0; i<4; i++) {vorm[i].r = 9}}
function button8Action()
{for (let i=0; i<4; i++) {vorm[i].r = 8}}
function button7Action()
{for (let i=0; i<4; i++) {vorm[i].r = 7}}
function buttonDAction(){save('gouden_driehoek_vijf.png')}