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

code comments

This commit is contained in:
Pomax
2020-09-19 22:51:19 -07:00
parent 4c0e71cd4a
commit d77d3649b6
27 changed files with 97 additions and 61 deletions

View File

@@ -28,11 +28,15 @@ draw() {
plotDistanceFunction(w, h, len) {
noFill();
// There is no way we're capturing the distance function as a nice
// easy function, so instead we're going to do the next best thing:
// sample the curve at a number of points, and then construct the
// function plot as we walk from one sample to the next.
let LUT = curve.getLUT(this.steps * 10);
let d = 0;
start();
vertex(0,0);
for(let i=1, e=LUT.length, p1, p2; i<e; i++) {
for(let i=1, e=LUT.length, p1, p2, d=0; i<e; i++) {
p1 = LUT[i-1];
p2 = LUT[i];
d += dist(p1.x, p1.y, p2.x, p2.y);

View File

@@ -23,9 +23,12 @@ draw() {
scale(0.85);
translate(30,30);
// This first part is the same as the previous graphic
setFill(`black`);
drawAxes("t", 0, 1, "d", 0, len|0, w, h);
let LUT = this.plotDistanceFunction(w, h, len);
// but this part is new.
this.drawPlotIntervals(w, h, LUT);
resetTransform();