An options map for the resolvers, and sid beside the clip it is in
Finishing the last commit, which traded a simpler definition for noisier call
sites: deleting the arity ladders left `(symbol/resolver sym st pal/index-of
nil nil)` at twenty-odd places, and two trailing nils tell a reader nothing
except to go and count positions.
The ladder was a symptom. The disease is five positional parameters, and the
split that matters is which of them are OPTIONAL:
store, palette positional, because neither is optional. A dense channel
cannot be read without the store it names — that is the
crash two commits ago — and every op carries a colour.
pose-tracks one call site, in `clip/resolver`'s own recursion
source/picture-fps two call sites
So the last three become one `opts` map, and the common call loses a nil. The
point is not the nil: it is that the sixth option, whenever it arrives, is a
key at one call site rather than a nil at fifty.
`clip/resolver` also had `sid` FOURTH, behind two arguments that say nothing
about which symbol is being resolved. It is second now, beside the clip it is
in: `(clip/resolver c :main store pal/index-of nil)`.
62 call sites rewritten by parsing the forms rather than by regex, because
`clip/resolver`'s arguments move past each other and a regex cannot see that.
An earlier attempt at this dropped `palette` on the floor and still compiled
at 62 sites — it only surfaced as an arity error, so if that had been a
same-arity mistake the tests would have been the last line of defence.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
ee66680a0c
commit
624242b407
20 changed files with 84 additions and 81 deletions
|
|
@ -26,4 +26,4 @@
|
|||
"Draw ops for one frame, via the specification path. The page uses
|
||||
`symbol/resolver` instead; this is here for the REPL."
|
||||
[f]
|
||||
(symbol/eval-frame main f nil pal/index-of nil nil))
|
||||
(symbol/eval-frame main f nil pal/index-of nil))
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@
|
|||
own frame. Nil for a node that was not on that frame. It is how something
|
||||
drawn beside the picture, like a tracing photo, rides a node inside it without
|
||||
resolving anything a second time."
|
||||
[clip store palette sid {:keys [picture-fps] :as opts}]
|
||||
[clip sid store palette {:keys [picture-fps] :as opts}]
|
||||
(letfn [(build [sid chain pose-tracks]
|
||||
(when (some #{sid} chain)
|
||||
(throw (ex-info "symbol cycle" {:chain (conj chain sid)})))
|
||||
|
|
@ -183,8 +183,9 @@
|
|||
nodes (:nodes sym)
|
||||
rank (symbol/draw-rank nodes (symbol/order nodes))
|
||||
ids (sort-by rank (keys nodes))
|
||||
own (symbol/resolver sym store palette pose-tracks
|
||||
(assoc opts :source-fps (:fps clip)))
|
||||
own (symbol/resolver sym store palette
|
||||
(assoc opts :pose-tracks pose-tracks
|
||||
:source-fps (:fps clip)))
|
||||
children (into {}
|
||||
(for [[id n] nodes :when (= :instance (:kind n))]
|
||||
[id (build (:of n) (conj chain sid)
|
||||
|
|
@ -243,7 +244,7 @@
|
|||
Effects' anchor point are set once and left. A symbol that grows later keeps
|
||||
its instances' pivots where they were, so nothing on screen moves."
|
||||
[clip store sid]
|
||||
(let [resolve (resolver clip store pal/index-of sid nil)
|
||||
(let [resolve (resolver clip sid store pal/index-of nil)
|
||||
bounds (fn [[x0 y0 x1 y1 :as b] x y]
|
||||
(if b [(min x0 x) (min y0 y) (max x1 x) (max y1 y)] [x y x y]))
|
||||
[x0 y0 x1 y1]
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
[clip store sid frame id]
|
||||
(let [sym (clip/symbol clip sid)
|
||||
sym (update sym :nodes select-keys (symbol/lineage (:nodes sym) id))
|
||||
r (symbol/resolver sym store pal/index-of nil {:source-fps (:fps clip)})]
|
||||
r (symbol/resolver sym store pal/index-of {:source-fps (:fps clip)})]
|
||||
(r frame)
|
||||
r))
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@
|
|||
(let [sid (:of n)
|
||||
frames (clip/frames document sid)
|
||||
loop? (get-in n [:time :loop?])
|
||||
resolve (clip/resolver document store pal/index-of sid nil)]
|
||||
resolve (clip/resolver document sid store pal/index-of nil)]
|
||||
(fn [f]
|
||||
(let [f (if loop? (mod f frames) f)]
|
||||
(when (< -1 f frames)
|
||||
|
|
|
|||
|
|
@ -26,11 +26,13 @@
|
|||
|
||||
Two ways to evaluate one at a frame:
|
||||
|
||||
(eval-frame sym f store) THE SPECIFICATION. Allocating, order-free,
|
||||
(eval-frame sym f store palette opts)
|
||||
THE SPECIFICATION. Allocating, order-free,
|
||||
obviously correct. Use it in tests and for a
|
||||
one-off render.
|
||||
|
||||
(resolver sym store) -> (fn [f] ops). What playback uses. Caches the
|
||||
(resolver sym store palette opts)
|
||||
-> (fn [f] ops). What playback uses. Caches the
|
||||
topological order and the z paths, holds one
|
||||
CURSOR per channel and one PREALLOCATED point
|
||||
buffer per node, so a frame allocates the op
|
||||
|
|
@ -422,11 +424,10 @@
|
|||
the only place the space changes.
|
||||
|
||||
This is the definition of what a frame means. `resolver` is what plays it."
|
||||
[sym f store palette pose-tracks opts]
|
||||
[sym f store palette {:keys [pose-tracks source-fps picture-fps]}]
|
||||
(let [nodes (nodes-of sym)
|
||||
choices (pose/prepare pose-tracks)
|
||||
traces (prepared-traces nodes)
|
||||
{:keys [source-fps picture-fps]} opts
|
||||
ord (order nodes)]
|
||||
(eval-into {:read (fn [id path c lf]
|
||||
(ch/value-at c (channel-frame choices traces nodes
|
||||
|
|
@ -481,8 +482,15 @@
|
|||
|
||||
The op maps themselves are allocated fresh, and deliberately: there are a dozen
|
||||
of them per frame against hundreds of points, so pooling them would buy
|
||||
nothing and cost the ability to hand an op list around as plain data."
|
||||
[sym store palette pose-tracks {:keys [source-fps picture-fps]}]
|
||||
nothing and cost the ability to hand an op list around as plain data.
|
||||
|
||||
`store` and `palette` are POSITIONAL because neither is optional: a dense
|
||||
channel cannot be read without the store it names, and every op carries a
|
||||
colour index. `opts` is a map because the rest genuinely are optional, and
|
||||
because a fifth of them later is then a key rather than a nil at every one of
|
||||
these call sites — which is what the arity ladder that used to be here was
|
||||
standing in for."
|
||||
[sym store palette {:keys [pose-tracks source-fps picture-fps]}]
|
||||
(let [nodes (nodes-of sym)
|
||||
choices (pose/prepare pose-tracks)
|
||||
traces (prepared-traces nodes)
|
||||
|
|
|
|||
|
|
@ -195,8 +195,7 @@
|
|||
;; inside it still resolve — clip/resolver is the function that knows
|
||||
;; how.
|
||||
doc (assoc-in clip [:symbols sid] sym)
|
||||
resolve-frame (clip/resolver doc store palette sid
|
||||
{:picture-fps picture-fps})
|
||||
resolve-frame (clip/resolver doc sid store palette {:picture-fps picture-fps})
|
||||
ras (raster/make width height)
|
||||
bg (get palette :bg 0)]
|
||||
(-> (audio! doc sid store audio-url)
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@
|
|||
:<- [::playback/display-fps]
|
||||
(fn [[document sid store palette picture-fps] _]
|
||||
(when (and document (clip/symbol document sid))
|
||||
(clip/resolver document store palette sid {:picture-fps picture-fps}))))
|
||||
(clip/resolver document sid store palette {:picture-fps picture-fps}))))
|
||||
|
||||
(rf/reg-sub
|
||||
::shown
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
:disc (select-keys op [:kind :cx :cy :r])
|
||||
:rect (select-keys op [:kind :cx :cy :size])
|
||||
nil))
|
||||
((clip/resolver document st pal/index-of sid nil) 0))))
|
||||
((clip/resolver document sid st pal/index-of nil) 0))))
|
||||
|
||||
(defn symbol!
|
||||
"Start carrying symbol `sid` of the loaded document into the open symbol."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue