schets met vier trapeziums en vier 3d hoeken.                                      terug naar de inleiding
toets "s" stopt de rotaties iedere andere toets start de rotaties weer
                                                                                                         hoeken en trapeziums in fullscreen
 
de schets maakt gebruik van de objectmethodes van de p5.js superclass:  "Vormen" en objecten van de subclasses:  "Hoek3d_na2n""Trap_2nn""Rechthoek"   en  "Ruitjes"   
                
 

 
let vorm = []; let ruitjespap; let ruitjes; let zwartwit = false; 
function setup() { 
 buttonR1 = createButton('reset'); 
 buttonR1.position(20,30);buttonR1.style('width','70px'); 
 buttonR1.mouseClicked(buttonR1Action); 
 buttonLb = createButton('brede gekleurde lijnen'); 
 buttonLb.position(20,60);buttonLb.style('width','150px'); 
 buttonLb.mouseClicked(buttonLbAction); 
 buttonZW = createButton('zwart/wit'); 
 buttonZW.position(20,90);buttonZW.style('width','100px'); 
 buttonZW.mouseClicked(buttonZWAction); 
 buttonRuitAU = createButton('ruitjes aan/uit'); 
 buttonRuitAU.position(20,120);buttonRuitAU.style('width','100px'); 
 buttonRuitAU.mouseClicked(buttonRuitAUAction); 
 buttonD = createButton('downloaden'); 
 buttonD.position(20,150);buttonD.style('width','100px'); 
 buttonD.mouseClicked(buttonDAction); 
 createCanvas(windowWidth, windowHeight); 
 let x = width/2; let y = height/2; let n = height/10; 
 let hn = sqrt(3*n*n/4); 
 let ch1 = color(255,0,0,50); let ch2 = color(0,255,0,100); 
 let ch3 = color(0,0,255,100); let ch4 = color(255,255,0,100); 
 let ch5 = color(255,0,255,100); let sw = n/100; let sc = color(0); 
 let alfa = 100; 
 vorm[0] = new Trap_2nn(n, 1, x, y-(n/2+hn), 180, color(255,255,0, alfa),sw,sc); 
 vorm[1] = new Trap_2nn(n, 7, x, y-(n/2+hn), 180, color(255, 0, 0, alfa),sw,sc); 
 vorm[2] = new Trap_2nn(n, 7, x, y+n/2+hn, 0, color(0, 0, 255, alfa),sw,sc); 
 vorm[3] = new Trap_2nn(n, 1, x, y+n/2+hn, 0, color(0, 255, 0, alfa),sw,sc); 
 vorm[4] = new Rechthoek(n,n, 0, x-n, y, 0, color(0, 255, 0, alfa),sw,sc); 
 vorm[5] = new Rechthoek(n,n, 0, x+n, y, 0, color(255,255,0, alfa),sw,sc); 
 vorm[6] = new Hoek3d_na2n(n, 6, x-2*n, y-(n/2+hn), 135, ch1,ch2,ch3,ch4,ch5,sw,sc); 
 vorm[7] = new Hoek3d_na2n(n, 2, x+2*n, y-(n/2+hn),-135, ch1,ch2,ch3,ch4,ch5,sw,sc); 
 vorm[8] = new Hoek3d_na2n(n, 2, x-2*n, y+n/2+hn, 45, ch1,ch2,ch3,ch4,ch5,sw,sc); 
 vorm[9] = new Hoek3d_na2n(n, 6, x+2*n, y+n/2+hn, -45, ch1,ch2,ch3,ch4,ch5,sw,sc); 
 ruitjespap = new Ruitjes(n,x,y); 
} 
 function draw() { 
 if (zwartwit) {background(0)} 
 else {clear(); background('rgba(255,255,255, 0)');} 

 
for (let i=0; i<10; i++){vorm[i].display()} 

 
if (ruitjes){ruitjespap.display(); 
 for(let i=0; i<10; i++){vorm[i].dpAan();}} 

 
if (key == 's' || key == 'S') { } 
 else 
 { 
 vorm[6].dpRotLi(vorm[6]); vorm[7].dpRotRe(vorm[7]); 
 vorm[8].dpRotRe(vorm[8]); vorm[9].dpRotLi(vorm[9]); 
 vorm[0].dpRotRe(vorm[0]); vorm[1].dpRotLi(vorm[1]); 
 vorm[2].dpRotLi(vorm[2]); vorm[3].dpRotRe(vorm[3]); 
 } 
} 

 
function buttonR1Action(){setup();} 
 function buttonLbAction(){for(let i=0; i<10; i++) {vorm[i].sw=height/20; 
 vorm[i].sc=color(random(250),random(200),random(200),100)}} 
 function buttonZWAction() 
 {if(zwartwit){zwartwit = false;} else {zwartwit=true;}} 
 function buttonRuitAUAction() 
 {if(ruitjes){ruitjes=false;}else{ruitjes=true;}} 
 function buttonDAction(){save('hoekbalken_trapeziums.png');} 

dit is digitale kunst