Model palette tracks as typed symbol lanes

This commit is contained in:
Your Name 2026-10-02 10:06:05 -04:00
parent dff23d7994
commit 26fab9392e
20 changed files with 371 additions and 123 deletions

View file

@ -318,3 +318,40 @@
"the inheriting child follows the lightning cut; an instance override wins")
(is (= [17 34 51] (nth (:ramp context) 1)))
(is (= [170 187 204] (nth (:ramp context) 3)))))
(deftest symbol-authoring-palettes-seed-only-the-view-root
(let [palette (fn [id name color]
{:id id :name name :slots [{:hex color} {:hex color}]})
mark {:id :mark :kind :rect :z "a1"
:channels {[:geom :size] (ch/framed 2)
[:style :color] (ch/framed 1)}}
document {:fps 30 :width 20 :height 20
:palettes {:day (palette :day "Day" "#112233")
:night (palette :night "Night" "#aabbcc")}
:default-palette :day
:symbols
{:main {:id :main :frames 4 :palette :day :palette-track :palette-lane
:nodes {:child {:id :child :kind :instance :z "a1"
:source {:symbol :drawing}}}}
:palette-lane {:id :palette-lane :name "palette"
:type :palette-track :display :lane :frames 4
:nodes {:night {:id :night :kind :instance :z "a1"
:source {:symbol :night-palette}
:span [0 1] :time {:at 1}}}}
:night-palette {:id :night-palette :name "Night"
:type :palette :palette-ref :night
:frames 1 :nodes {}}
:drawing {:id :drawing :frames 4 :palette :night
:nodes {:mark mark}}}}
context (pal/compile document)
main (clip/resolver document :main nil context nil)
drawing (clip/resolver document :drawing nil context nil)
color #(-> (%1 %2) first :color)]
(is (= (pal/render-index context :day 1) (color main 0))
"a nested symbol's authoring palette does not override the viewed root")
(is (= (pal/render-index context :night 1) (color main 1))
"a covered palette-track interval overrides the root fallback")
(is (= (pal/render-index context :day 1) (color main 2))
"a nil track interval is a real gap and restores the authoring palette")
(is (= (pal/render-index context :night 1) (color drawing 0))
"the same nested symbol uses its authoring palette when viewed directly")))

View file

@ -90,3 +90,26 @@
(deftest host-frame-of-a-parentless-clip-is-the-symbol-frame
(is (= 6 (span/host-frame (document) :main :b 6)))
(is (= 6 (span/host-frame (ordinary-document) :main :badge 6))))
(deftest typed-symbol-containment-applies-to-every-transfer
(let [palette-node {:id :p :kind :instance :z "a1"
:source {:symbol :night-palette}
:span [0 1] :time {:at 0}}
visual-node {:id :v :kind :instance :z "a1"
:source {:symbol :drawing}
:span [0 1] :time {:at 0}}
doc {:fps 30 :width 20 :height 20
:symbols
{:root {:id :root :frames 8 :nodes {}}
:ordinary-lane {:id :ordinary-lane :frames 8 :display :lane :nodes {}}
:palette-lane {:id :palette-lane :frames 8 :display :lane
:type :palette-track :nodes {:p palette-node}}
:night-palette {:id :night-palette :frames 1 :type :palette
:palette-ref :night :nodes {}}
:drawing {:id :drawing :frames 1 :nodes {}}}}]
(is (:refused (span/transfer doc :palette-lane :p :root 0 {}))
"a palette clip cannot escape to a composition root")
(is (:refused (span/transfer doc :palette-lane :p :ordinary-lane 0 {}))
"a palette clip cannot escape to an ordinary lane")
(is (:refused (span/place-node doc :palette-lane visual-node 0 {}))
"a palette lane refuses ordinary visual clips")))