vijf vijfhoeken vormen een vijfhoek.       terug naar de inleiding
toets "s"  stoppen van de rotaties met iedere ander toets starten de rotaties weer.

                                                                                 roterende vijfhoeken in fullscreen

vijf vijfhoeken vormen een vijfhoek in p5.js
 
de schets maakt gebruik van objecten van  de p5.js class "Vhoek_n5" en de superclass "Vormen"
 
 
   let vorm = [];
function setup() {
  buttonR = createButton('reset');
  buttonR.position(20,40);buttonR.style('width','70px');
  buttonR.mouseClicked(buttonRAction);
  button0 = createButton('dp 0');
  button0.position(20,80);button0.style('width','70px');
  button0.mouseClicked(button0Action);
  button1 = createButton('dp 1');
  button1.position(20,120);button1.style('width','70px');
  button1.mouseClicked(button1Action);
  button2 = createButton('dp 2');
  button2.position(20,160);button2.style('width','70px');
  button2.mouseClicked(button2Action);
  button3 = createButton('dp 3');
  button3.position(20,200);button3.style('width','70px');
  button3.mouseClicked(button3Action);
  button4 = createButton('dp 4');
  button4.position(20,240);button4.style('width','70px');
  button4.mouseClicked(button4Action);
  button5 = createButton('dp 5');
  button5.position(20,280);button5.style('width','70px');
  button5.mouseClicked(button5Action);
  button6 = createButton('dp 6');
  button6.position(20,320);button6.style('width','70px');
  button6.mouseClicked(button6Action);
  buttonD = createButton('downloaden');
  buttonD.position(20,360);buttonD.style('width','130px');
  buttonD.mouseClicked(buttonDAction);
 
  createCanvas(windowWidth, windowHeight);
  let x = width/2; let y = height/2; let n = height/5;
  let rl = sqrt(50+10*sqrt(5))*n/10;
  let rk = sqrt(25+10*sqrt(5))*n/10;
  let phi= ((1+sqrt(5))/2);
  let nphi = n+n/phi;
  let bl = rl/(2*phi);
  let sw = n/150; let alfa = 100; let sc = color(0);
  vorm[0]= new Vhoek_n5(n,0,x,       y-rl, 0,  color(53,145,250,alfa), sw,sc);
  vorm[1]= new Vhoek_n5(n,0,x-n/2,   y+rk,-144,color(53,250,87, alfa), sw,sc);
  vorm[2]= new Vhoek_n5(n,0,x-nphi/2,y-bl, -72,color(259,208,53,alfa), sw,sc);
  vorm[3]= new Vhoek_n5(n,0,x+nphi/2,y-bl, 72, color(255,116,103,alfa),sw,sc);
  vorm[4]= new Vhoek_n5(n,0,x+n/2,   y+rk, 144,color(239,140,252,alfa),sw,sc);
}
function draw() {
  clear();
  background('rgba(255,255,255, 0)');
   for (let i=0; i<5; i++) {vorm[i].display();}
 
  if (key == 's' || key == 'S') { }
   else
 {
  vorm[0].dpRotRe(vorm[0]); vorm[1].dpRotRe(vorm[1]);
  vorm[2].dpRotRe(vorm[2]); vorm[3].dpRotRe(vorm[3]);
  vorm[4].dpRotRe(vorm[4]);
  }
}
 
function windowResize() {
  resizeCanvas(windowWidth, windowHeight);
}
 
function buttonRAction(){setup();}
function button0Action(){for (let i=0; i<5; i++) {vorm[i].d = 0;}}
function button1Action(){for (let i=0; i<5; i++) {vorm[i].d = 1;}}
function button2Action(){for (let i=0; i<5; i++) {vorm[i].d = 2;}}
function button3Action(){for (let i=0; i<5; i++) {vorm[i].d = 3;}}
function button4Action(){for (let i=0; i<5; i++) {vorm[i].d = 4;}}
function button5Action(){for (let i=0; i<5; i++) {vorm[i].d = 5;}}
function button6Action(){for (let i=0; i<5; i++) {vorm[i].d = 6;}}
function buttonDAction(){save('vijf_vijfhoeken.png');}
 

 
 

 

 

vijf vijhoeken06