1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-08-29 02:59:58 +02:00

this rename is absolutely stupid

This commit is contained in:
Pomax
2020-08-20 13:01:32 -07:00
parent 59fdafb2c5
commit d92e370bd1
470 changed files with 22 additions and 9 deletions

View File

@@ -0,0 +1,80 @@
setup() {
this.t = 0.5;
this.curve = Bezier.defaultCubic(this);
setMovable(this.curve.points);
}
draw() {
resetTransform();
clear();
let p = this.curve.get(this.t);
const struts = this.struts = this.curve.getStrutPoints(this.t);
const c1 = new Bezier(this, [struts[0], struts[4], struts[7], struts[9]]);
const c2 = new Bezier(this, [struts[9], struts[8], struts[6], struts[3]]);
this.drawBasics(p);
translate(this.width/3, 0);
setStroke(`black`);
line(0, 0, 0, this.height);
this.drawSegment(c1, p);
translate(this.width/3, 0);
setStroke(`black`);
line(0, 0, 0, this.height);
this.drawSegment(c2, p);
}
drawBasics(p) {
this.curve.drawCurve(`lightgrey`);
this.curve.drawSkeleton(`lightgrey`);
this.curve.drawPoints(false);
noFill();
setStroke(`red`);
circle(p.x, p.y, 3);
setStroke(`lightblue`);
this.curve.drawStruts(this.struts);
setFill(`black`)
text(`The full curve, with struts`, 10, 15);
}
drawSegment(c, p) {
setStroke(`lightblue`);
this.curve.drawCurve(`lightblue`);
this.curve.drawSkeleton(`lightblue`);
this.curve.drawStruts(this.struts);
c.drawCurve();
c.drawSkeleton(`black`);
noFill();
setStroke(`red`);
circle(p.x, p.y, 3);
setFill(`black`)
text(`The first half`, 10, 15);
}
onKeyDown() {
let key = this.keyboard.currentKey;
if(key === `ArrowUp`) {
this.t += 0.01;
}
if(key === `ArrowDown`) {
this.t -= 0.01
}
this.t = this.t < 0 ? 0 : this.t > 1 ? 1 : this.t;
redraw();
}
onMouseMove() {
if (this.cursor.down && !this.currentPoint) {
this.t = map(this.cursor.y, 0,this.height, 0, 1);
}
redraw();
}