1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-08-23 00:33:12 +02:00

t-value control

This commit is contained in:
Pomax
2018-06-23 23:22:58 -07:00
parent 1da8c3966b
commit 3d334c2559
13 changed files with 4301 additions and 1907 deletions

View File

@@ -2382,6 +2382,7 @@ return {
toggle: function() {
if (this.api) {
this.customTimeValues = false;
this.mode = (this.mode + 1) % fit.modes.length;
this.fitCurve(this.api);
this.api.redraw();
@@ -2395,22 +2396,33 @@ return {
api.drawGrid(10,10);
api.setColor('black');
if (!this.curveset && this.points.length > 2) {
this.fitCurve(api);
curve = this.fitCurve(api);
}
if (curve) {
api.drawCurve(curve);
api.drawSkeleton(curve);
}
api.drawPoints(this.points);
api.setFill(0);
api.text("using "+fit.modes[this.mode]+" t values", {x: 5, y: 10});
if (!this.customTimeValues) {
api.setFill(0);
api.text("using "+fit.modes[this.mode]+" t values", {x: 5, y: 10});
}
},
fitCurve(api) {
let bestFitData = fit(this.points, this.mode),
processTimeUpdate(sliderid, timeValues) {
var api = this.api;
this.customTimeValues = true;
this.fitCurve(api, timeValues);
api.redraw();
},
fitCurve(api, timeValues) {
let bestFitData = fit(this.points, timeValues || this.mode),
x = bestFitData.C.x,
y = bestFitData.C.y,
bpoints = [];
@@ -2423,6 +2435,8 @@ return {
var curve = new api.Bezier(bpoints);
api.setCurve(curve);
this.curveset = true;
this.sliders.setOptions(bestFitData.S);
return curve;
},
onClick: function(evt, api) {