Skip to content

Commit ab8be8b

Browse files
vipenzoclaude
andcommitted
Fix capped with negative radius: correct easing and sign handling
- Remove Math/abs on inset-amount so negative radius expands the shape - Use sin easing for negative radius (gradual expansion) vs quarter-circle for positive radius (convex fillet) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 44bae0a commit ab8be8b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/ridley/turtle/shape_fn.cljs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -946,8 +946,11 @@
946946
:or {mode :fillet start true end true
947947
preserve-holes true}}]
948948
(let [ease-fn (case mode
949-
:fillet (fn [u] (Math/sqrt (- (* 2 u) (* u u))))
950-
:chamfer (fn [u] u))
949+
:fillet (fn [u r]
950+
(if (neg? r)
951+
(Math/sin (* u (/ Math/PI 2)))
952+
(Math/sqrt (- (* 2 u) (* u u)))))
953+
:chamfer (fn [u _r] u))
951954
start-radius radius
952955
end-radius (or end-radius radius)
953956
explicit-fraction fraction]
@@ -964,17 +967,17 @@
964967
[in-transition? u active-radius]
965968
(cond
966969
(and start (< t fraction))
967-
[true (ease-fn (/ t fraction)) start-radius]
970+
[true (ease-fn (/ t fraction) start-radius) start-radius]
968971

969972
(and end (> t (- 1 fraction)))
970-
[true (ease-fn (/ (- 1 t) fraction)) end-radius]
973+
[true (ease-fn (/ (- 1 t) fraction) end-radius) end-radius]
971974

972975
:else [false 1.0 0])]
973976
(if (or (not in-transition?) (>= u 0.999))
974977
s
975978
;; Scale shape toward centroid — preserves proportions (fillet radii etc.)
976979
;; The radius parameter controls how much the nearest edge moves inward.
977-
(let [inset-amount (* (Math/abs active-radius) (- 1 u))
980+
(let [inset-amount (* active-radius (- 1 u))
978981
inradius (xform/shape-inradius s)
979982
scale (if (> inradius 0.001)
980983
(max 0.001 (/ (- inradius inset-amount) inradius))

0 commit comments

Comments
 (0)