From e20620b85edde4a8bd241948057ee8443909482d Mon Sep 17 00:00:00 2001 From: Orion Reed Date: Sun, 15 Dec 2024 07:05:21 -0500 Subject: [PATCH] nonlinear stretch --- src/folk-rope.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/folk-rope.ts b/src/folk-rope.ts index f5bc942..30cd6c6 100644 --- a/src/folk-rope.ts +++ b/src/folk-rope.ts @@ -142,7 +142,10 @@ export class FolkRope extends FolkBaseConnection implements AnimationFrameContro // Calculate desired length based on source and target positions const distance = Vector.distance(this.sourceRect, this.targetRect); - const desiredPoints = Math.floor(distance / FolkRope.#resolution); + // Apply a nonlinear scaling to gradually increase point spacing with distance + const scaleFactor = Math.log10(distance + 10) / 2; // adjust the '+10' and '/2' to tune the curve + const effectiveResolution = FolkRope.#resolution * scaleFactor; + const desiredPoints = Math.floor(distance / effectiveResolution); while (this.#points.length < desiredPoints) { const lastPoint = this.#points.at(-1)!;