(compute-pointer-offset rest-x
rest-y
pointer-x
pointer-y
grab-radius
intensity
grabbed?)Compute the displacement offset for a single control point based on pointer position. Returns #js [offset-x offset-y]. When the pointer is outside grab-radius, returns [0, 0].
Compute the displacement offset for a single control point based on pointer position. Returns #js [offset-x offset-y]. When the pointer is outside grab-radius, returns [0, 0].
(derive-state {:keys [stiffness-raw damping-raw radius-raw intensity-raw
grab-radius-raw disabled-attr]})Normalise raw attribute inputs into a stable view-model map.
Input keys: :stiffness-raw string | nil :damping-raw string | nil :radius-raw string | nil :intensity-raw string | nil :grab-radius-raw string | nil :disabled-attr string | nil (nil when absent)
Output keys: :stiffness number :damping number :radius number :intensity number :grab-radius number :disabled? boolean
Normalise raw attribute inputs into a stable view-model map. Input keys: :stiffness-raw string | nil :damping-raw string | nil :radius-raw string | nil :intensity-raw string | nil :grab-radius-raw string | nil :disabled-attr string | nil (nil when absent) Output keys: :stiffness number :damping number :radius number :intensity number :grab-radius number :disabled? boolean
(generate-rest-points w h r)Compute 20 rest-position control points around a rounded rect of size w×h with corner radius r. Returns two JS arrays [xs, ys] each of length 20.
Each side contributes 5 points: 3 along the straight edge, then 2 on the following quarter-circle corner arc (at 30° and 60° of the arc). The arc entry/exit points coincide with the first/last edge points of adjacent sides, so the corner is smoothly bridged.
Layout (clockwise from top-left arc exit): 0-2: top edge (left→right) 3-4: top-right arc (30° and 60°) 5-7: right edge (top→bottom) 8-9: bottom-right arc 10-12: bottom edge (right→left) 13-14: bottom-left arc 15-17: left edge (bottom→top) 18-19: top-left arc
Compute 20 rest-position control points around a rounded rect of size w×h with corner radius r. Returns two JS arrays [xs, ys] each of length 20. Each side contributes 5 points: 3 along the straight edge, then 2 on the following quarter-circle corner arc (at 30° and 60° of the arc). The arc entry/exit points coincide with the first/last edge points of adjacent sides, so the corner is smoothly bridged. Layout (clockwise from top-left arc exit): 0-2: top edge (left→right) 3-4: top-right arc (30° and 60°) 5-7: right edge (top→bottom) 8-9: bottom-right arc 10-12: bottom edge (right→left) 13-14: bottom-left arc 15-17: left edge (bottom→top) 18-19: top-left arc
(parse-disabled s)Parse disabled attribute. Present (any value) → true, nil → false.
Parse disabled attribute. Present (any value) → true, nil → false.
20 control points: per side 3 edge points + 2 corner arc points = 5 × 4.
20 control points: per side 3 edge points + 2 corner arc points = 5 × 4.
(points->path-d xs ys n)Build a smooth closed SVG path through n control points using Catmull-Rom → cubic bezier conversion with handle-length clamping to prevent overshoot at corners. xs, ys are Float64Arrays of length n.
Build a smooth closed SVG path through n control points using Catmull-Rom → cubic bezier conversion with handle-length clamping to prevent overshoot at corners. xs, ys are Float64Arrays of length n.
(spring-step current target velocity dt stiffness damping)Single step of damped spring physics (1D). Returns #js [new-position new-velocity].
Single step of damped spring physics (1D). Returns #js [new-position new-velocity].
(static-rounded-rect-d w h r)Return an SVG path d-string for a simple rounded rectangle.
Return an SVG path d-string for a simple rounded rectangle.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |