animatie met pentomino's "F" en "X". terug naar de inleiding
Toets "s" stopt de rotaties de overige toetsen starten de rotaties
pentomino's "F" en "X" in fullscreen
de schets in p5.js
vorm = []; let ruitjespap; let rond=false; let blend=false;
let x; let y; let n; let kleurzh=false;let lijnau=true;
function setup() {
button0 = createButton('reset');
button0.position(20,30);button0.style('width','70px');
button0.mouseClicked(button0Action);
button1 = createButton('(2,3)');
button1.position(20,60);button1.style('width','70px');
button1.mouseClicked(button1Action);
button2 = createButton('(3,2)');
button2.position(20,90);button2.style('width','70px');
button2.mouseClicked(button2Action);
button3 = createButton('(1,2)');
button3.position(20,120);button3.style('width','70px');
button3.mouseClicked(button3Action);
button4 = createButton('(2,1)');
button4.position(20,150);button4.style('width','70px');
button4.mouseClicked(button4Action);
button5 = createButton('(1,1)');
button5.position(20,180);button5.style('width','70px');
button5.mouseClicked(button5Action);
button7 = createButton('dp 1');
button7.position(100,60);button7.style('width','70px');
button7.mouseClicked(button7Action);
button8 = createButton('dp 2');
button8.position(100,90);button8.style('width','70px');
button8.mouseClicked(button8Action);
button9 = createButton('dp 3');
button9.position(100,120);button9.style('width','70px');
button9.mouseClicked(button9Action);
buttonKZH =createButton('kleur hard/zacht');
buttonKZH.position(20,210); buttonKZH.style('width','140px');
buttonKZH.mouseClicked(buttonKZHAction);
buttonRAU = createButton('rond aan/uit');
buttonRAU.position(20,240); buttonRAU.style('width','100px')
buttonRAU.mouseClicked(buttonRAUAction);
buttonLAU= createButton('lijn aan/uit');
buttonLAU.position(20,270);buttonLAU.style('width','100px');
buttonLAU.mouseClicked(buttonLAUAction);
buttonBM = createButton('Blendmode');
buttonBM.position(20,300);buttonBM.style('width','100px');
buttonBM.mouseClicked(buttonBMAction);
buttonD = createButton('downloaden');
buttonD.position(20,330);buttonD.style('width','100px');
buttonD.mouseClicked(buttonDAction);
createCanvas(windowWidth, windowHeight);
x = width/2; y = height/2; n = height/12;
let sw = height/500; let alfa = 50; let kleur = 0;
ruitjespap = new Ruitjes(n,x,y);
vorm[0] = new X(n, 4,x-4*n,y-3*n, 0,color(255,255,0,alfa),sw,color(kleur));
vorm[1] = new F(n, 1, 9,x-4*n,y-3*n, 0,color(255,0, 0, alfa),sw,color(kleur));
vorm[2] = new X(n, 9,x+4*n,y-3*n, 0,color(0,0, 255, alfa),sw,color(kleur));
vorm[3] = new F(n, 0, 2,x+4*n,y-3*n, 0,color(0,255, 0, alfa),sw,color(kleur));
vorm[4] = new X(n, 3,x-4*n,y+3*n, 0,color(0,0, 255, alfa),sw,color(kleur));
vorm[5] = new F(n, 0, 2,x-4*n,y+3*n,180,color(0,255, 0, alfa),sw,color(kleur));
vorm[6] = new X(n, 10,x+4*n,y+3*n, 0,color(255,255,0,alfa),sw,color(kleur));
vorm[7] = new F(n, 1, 9,x+4*n,y+3*n,180,color(255,0, 0, alfa),sw,color(kleur));
}
function draw() {
if (blend) {blendMode(DIFFERENCE)}
else {blendMode(BLEND)};
clear();
background('rgba(255,255,255, 0)');
for (let i = 0; i < 8; i++)
{
vorm[i].display();
}
if (key == 's' || key == 'S'){
}
else {
vorm[0].dpRotLi(vorm[0]);vorm[1].dpRotRe(vorm[1]);
vorm[2].dpRotRe(vorm[2]);vorm[3].dpRotLi(vorm[3]);
vorm[4].dpRotRe(vorm[4]);vorm[5].dpRotLi(vorm[5]);
vorm[6].dpRotLi(vorm[6]);vorm[7].dpRotRe(vorm[7]);
}
}
function button0Action(){setup();}
function button1Action()
{vorm[0].x=x-2*n;vorm[1].x=x-2*n;vorm[2].x=x+2*n;vorm[3].x=x+2*n;
vorm[4].x=x-2*n;vorm[5].x=x-2*n;vorm[6].x=x+2*n;vorm[7].x=x+2*n;
vorm[0].y=y-3*n;vorm[1].y=y-3*n;vorm[2].y=y-3*n;vorm[3].y=y-3*n;
vorm[4].y=y+3*n;vorm[5].y=y+3*n;vorm[6].y=y+3*n;vorm[7].y=y+3*n;}
function button2Action()
{vorm[0].x=x-3*n;vorm[1].x=x-3*n;vorm[2].x=x+3*n;vorm[3].x=x+3*n;
vorm[4].x=x-3*n;vorm[5].x=x-3*n;vorm[6].x=x+3*n;vorm[7].x=x+3*n;
vorm[0].y=y-2*n;vorm[1].y=y-2*n;vorm[2].y=y-2*n;vorm[3].y=y-2*n;
vorm[4].y=y+2*n;vorm[5].y=y+2*n;vorm[6].y=y+2*n;vorm[7].y=y+2*n;}
function button3Action()
{vorm[0].x=x-1*n;vorm[1].x=x-1*n;vorm[2].x=x+1*n;vorm[3].x=x+1*n;
vorm[4].x=x-1*n;vorm[5].x=x-1*n;vorm[6].x=x+1*n;vorm[7].x=x+1*n;
vorm[0].y=y-2*n;vorm[1].y=y-2*n;vorm[2].y=y-2*n;vorm[3].y=y-2*n;
vorm[4].y=y+2*n;vorm[5].y=y+2*n;vorm[6].y=y+2*n;vorm[7].y=y+2*n;}
function button4Action()
{vorm[0].x=x-2*n;vorm[1].x=x-2*n;vorm[2].x=x+2*n;vorm[3].x=x+2*n;
vorm[4].x=x-2*n;vorm[5].x=x-2*n;vorm[6].x=x+2*n;vorm[7].x=x+2*n;
vorm[0].y=y-1*n;vorm[1].y=y-1*n;vorm[2].y=y-1*n;vorm[3].y=y-1*n;
vorm[4].y=y+1*n;vorm[5].y=y+1*n;vorm[6].y=y+1*n;vorm[7].y=y+1*n;}
function button5Action()
{vorm[0].x=x-1*n;vorm[1].x=x-1*n;vorm[2].x=x+1*n;vorm[3].x=x+1*n;
vorm[4].x=x-1*n;vorm[5].x=x-1*n;vorm[6].x=x+1*n;vorm[7].x=x+1*n;
vorm[0].y=y-1*n;vorm[1].y=y-1*n;vorm[2].y=y-1*n;vorm[3].y=y-1*n;
vorm[4].y=y+1*n;vorm[5].y=y+1*n;vorm[6].y=y+1*n;vorm[7].y=y+1*n;}
function button7Action()
{vorm[0].d=6;vorm[1].d=7;vorm[2].d=7;vorm[3].d=4;
vorm[4].d=5;vorm[5].d=4;vorm[6].d=8;vorm[7].d=7;}
function button8Action()
{vorm[0].d=7;vorm[1].d=6;vorm[2].d=6;vorm[3].d=5;
vorm[4].d=6;vorm[5].d=5;vorm[6].d=7;vorm[7].d=6;}
function button9Action()
{vorm[0].d=8;vorm[1].d=5;vorm[2].d=5;vorm[3].d=8;
vorm[4].d=7;vorm[5].d=6;vorm[6].d=6;vorm[7].d=5;}
function buttonKZHAction() //lijnkleur zacht hard
{if (kleurzh) {for (let i = 0; i< 8; i++) {
vorm[i].c = color(random(0,200),random(0,255),random(0,255),100);
vorm[i].sc = color(random(0,200),random(0,255),random(0,255),100);
vorm[i].sw = n*0.7;}kleurzh = false}
else {for (let i = 0; i< 8; i++){
vorm[i].c = color(random(0,200),random(0,255),random(0,155),200);
vorm[i].sc = color(random(0,200),random(0,255),random(0,155),200);
vorm[i].sw = n*0.7;} kleurzh = true;}}
function buttonRAUAction(){if (rond) {strokeJoin(MITER); rond = false;}
else {strokeJoin(ROUND);rond = true};} //rondingen aan /uit
function buttonLAUAction() //lijn aan/uit
{if (lijnau) {for(let i = 0; i<8; i++){vorm[i].sw = 0;}lijnau = false;}
else {for(let i = 0; i<8; i++){vorm[i].sc=color(0);vorm[i].sw = height/500}lijnau = true}}
function buttonBMAction()
{if(blend){blend=false;} else {blend=true;}}
function buttonDAction(){save('pentomino_F_X.png');}