classes "Bezier2Cub" , "Bezier2Quadr" , "BezierCubQuadrCub" terug naar de inleiding
"Bezier2Cub" naar de Bezier cubic cubic curve constructor creator
class Bezier2Cub extends Curven {
constructor(xa1,ya1, xa2,ya2, xa3, ya3, //ankerpunten a1,a2,en a3
xc1,yc1, xc2,yc2, xc3, yc3,
xc4,yc4, c) //controlepunten c1, c2 en c3
{
super(xa1,ya1, xa2,ya2, xa3, ya3) //ankerpunten a1,a2,en a3 gaan naar de superclass
this.xa1 = xa1; this.ya1 = ya1; this.xa2 = xa2; this.ya2 = ya2; this.xa3 = xa3; this.ya3 = ya3;//a1 a2 en a3
this.xc1 = xc1; this.yc1 = yc1; this.xc2 = xc2; this.yc2 = yc2; this.xc3 = xc3; this.yc3 = yc3; //c1, c2 en c3
this.xc4 = xc4; this.yc4 = yc4; //c4
this.c = c;
}
display() {
fill(this.c);
beginShape();
vertex(this.xa1, this.ya1); //eerste ankerpunt
//eerste en tweede controlepunt en tweede ankerpunt
bezierVertex(this.xc1,this.yc1, this.xc2, this.yc2, this.xa2,this.ya2);
//derde en vierde controlepunt en derde ankerpunt
bezierVertex(this.xc3, this.yc3, this.xc4, this.yc4, this.xa3, this.ya3);
endShape(CLOSE);
}
}
class "Bezier2Quadr" naar de Bezier quadratic quadratic curve constructor creator
class Bezier2Quadr extends Curven {
constructor(xa1,ya1, xa2, ya2, xa3, ya3, //ankerpunten a1, a2 en a3
xc1,yc1, xc2,yc2, //controlepunten c1, en c2
c)
{
super(xa1,ya1, xa2, ya2, xa3, ya3) //ankerpunten a1, a2 en a3 gaan naar de superclass
this.xa1 = xa1; this.ya1 = ya1; this.xa2 = xa2; this.ya2 = ya2; this.xa3 = xa3; this.ya3 = ya3;//a1, a2 en a3
this.xc1 = xc1; this.yc1 = yc1; this.xc2 = xc2; this.yc2 = yc2; //c1 en c2
this.c = c;
}
display() {
fill(this.c);
beginShape();
vertex(this.xa1, this.ya1); //eerste ankerpunt
//quadraticVertex werkt alleen met WEBGL
quadraticVertex(this.xc1, this.yc1, this.xa2,this.ya2); //eerste controlepunt en tweede ankerpunt
quadraticVertex(this.xc2, this.yc2, this.xa3, this.ya3); //tweede ankerpunt en derde controlepunt
endShape(CLOSE);
}
}
class "BezierCubQuadrCub" naar de Bezier cubic quadratic cubic constructor creator
class BezierCubQuadrCub extends Curven {
constructor(xa1,ya1, xa2,ya2, xa3, ya3, xa4, ya4, //ankerpunten a1,a2,a3 en a4
xc1,yc1, xc2,yc2, xc3, yc3, xc4, yc4, xc5, yc5,//controlepunten c1, c2, c3, c4 en c5
c)
{
super(xa1,ya1, xa2,ya2, xa3, ya3, xa4, ya4) //ankerpunten a1,a2,a3 en a4 gaan naar de superclass
this.xa1 = xa1; this.ya1 = ya1; this.xa2 = xa2; this.ya2 = ya2;
this.xa3 = xa3; this.ya3 = ya3; this.xa4 = xa4; this.ya4 = ya4;
this.xc1 = xc1; this.yc1 = yc1; this.xc2 = xc2; this.yc2 = yc2;
this.xc3 = xc3; this.yc3 = yc3; this.xc4 = xc4; this.yc4 = yc4;
this.xc5 = xc5; this.yc5 = yc5; //c2, c3 en a3
this.c = c;
}
display() {
fill(this.c);
beginShape();
vertex(this.xa1, this.ya1); //eerste ankerpunt
bezierVertex(this.xc1, this.yc1, this.xc2, this.yc2, this.xa2, this.ya2); //eerste en tweede controlepunt en tweede ankerpunt
quadraticVertex(this.xc3,this.yc3, this.xa3,this.ya3); //derde controlepunt en derde ankerpunt
bezierVertex(this.xc4, this.yc4, this.xc5, this.yc5, this.xa4, this.ya4); //vierde en vijfde controlepunt en vierde ankerpunt
endShape(CLOSE);
}
}