Greetings!
I’m trying to create a class to draw a bezier curve but seeing ‘unexpected identifier’ error which doesn’t make sense to me : http://tiny.cc/xy7sbz
https://editor.p5js.org/VMK/sketches/D-GpdoGiM
Any help would be highly appreciated, thank you!
var activitesCurve = function(bzCurve) {
bzCurve.setup = function() {
var run = [25, 50, 60, 70];
var walk = [15, 75, 80, 40];
bzCurve = new BzCurve();
}
bzCurve.draw = function() {
bzCurve.show();
class BzCurve {
constructor() {
this.stroke = (239, 31, 193);
this.margin = 50;
this.height = bzCurve.windowHeight;
this.arr = run;
this.maxLength = run.length;
this.pointGap = position;
}
show() {
bezierCurve.stroke(this.stroke);
bezierCurve.beginShape();
bezierCurve.vertex(this.margin, this.height / 2 - this.arr[0]);
for (int i = 1; i < this.maxLength; i++) {
var posX = bezierCurve.float(i * this.pointGap + this.margin);
var posY = bezierCurve.float(this.height / 2 - this.arr[i]);
var c1 = bezierCurve.float((i - 1) * this.pointGap + this.margin);
var c2 = bezierCurve.float(this.height / 2 - this.arr[i - 1]);
var c3 = posX;
var c4 = posY;
bezierCurve.bezierVertex(c1, c2, c3, c4, posX, posY);
}
bezierCurve.endShape();
}
}
}
// Walk Line
bezierCurve.stroke(23, 225, 0);
bezierCurve.beginShape();
bezierCurve.vertex(margin, height / 2 - walk[0]);
for (int i = 1; i < walk.length; i++) {
var posWX = bezierCurve.float(i * pointGap + margin);
var posWY = bezierCurve.float(height / 2 - walk[i]);
var cW1 = bezierCurve.float((i - 1) * pointGap + margin);
var cW2 = bezierCurve.float(height / 2 - walk[i - 1]);
var cW3 = posWX;
var cW4 = posWY;
bezierCurve.bezierVertex(cW1, cW2, cW3, cW4, posWX, posWY);
}
}
var activitiesSketch = new p5(activitesCurve, 'activities');