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

projection, half moulding

This commit is contained in:
Pomax
2020-08-30 17:08:43 -07:00
parent 10148f46b1
commit e6608d65af
72 changed files with 448 additions and 251 deletions

View File

@@ -32,7 +32,7 @@ function getABC(n, S, B, E, t) {
x: B.x + (B.x - C.x) / s,
y: B.y + (B.y - C.y) / s,
};
return { A: A, B: B, C: C };
return { A, B, C };
}
/**
@@ -238,6 +238,15 @@ class Bezier {
return utils.length(this.derivative.bind(this));
}
getABC(t, B) {
let S = this.points[0];
let E = this.points[this.order];
let ret = getABC(this.order, S, B || this.get(t), E, t);
ret.S = S;
ret.E = E;
return ret;
}
getLUT(steps) {
this.verify();
steps = steps || 100;
@@ -248,8 +257,11 @@ class Bezier {
// We want a range from 0 to 1 inclusive, so
// we decrement and then use <= rather than <:
steps--;
for (let t = 0; t <= steps; t++) {
this._lut.push(this.compute(t / steps));
for (let i = 0, p, t; i < steps; i++) {
t = i / (steps - 1);
p = this.compute(t);
p.t = t;
this._lut.push(p);
}
return this._lut;
}