One palette per frame, chosen by the shallowest override in the open tab
A frame is drawn in exactly one palette, or one blend of two while a palette lane tweens. Shapes store slots and the raster index is the slot, so the palette is only the ramp a frame is expanded through: there is no way for two palettes' colours to share a frame. The per-palette index banks are gone. Every symbol drawn says which palette it chooses — its lane, its instance's palette, its own — and the shallowest wins, so a palette set on the open symbol beats anything inside it, and a child set to one turns the whole frame while it is drawn. Nothing chosen is the project's palette. The palette grid follows the palette the stage is in, per tab, read from the player rather than worked out again; mid-tween it holds the start palette. Another can be opened per tab, with a button back to the active one. The chooser puts the palettes the open symbol uses first, saying where, then the project's, then palettes made in other projects (with their project, and searchable by either name), each with the playhead's frame drawn in it; hovering previews on the stage, `use` sets the symbol to it. The classics are a folded shelf, now with VGA, Commodore 64, CGA and Workbench 1.3, and a new project carries only the palette it was made with. Unused slots are marked; solo shows and lets you click only what is drawn in the chosen colour; ⌫ empties the open palette's unused slots in place. The project palette can be changed in the inspector. The palette lane's label no longer collides with the sidebar grid's styles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
641f1fa18c
commit
1a6d6564c5
22 changed files with 865 additions and 428 deletions
|
|
@ -423,79 +423,95 @@
|
|||
(is (= [55 35] (gesture/pivot (gesture/values (get-in out [:symbols :main :nodes :cel]) 0 nil) nil))
|
||||
"and from then on it is the node's own, whatever the symbol does next"))))))
|
||||
|
||||
(deftest palette-context-is-inherited-keyed-and-overridable
|
||||
(let [palette (fn [id name a b]
|
||||
{:id id :name name :slots [{:hex a} {:hex b}]})
|
||||
(def ^:private one-palette-doc
|
||||
(let [palette (fn [id color] {:id id :name (name id) :slots [{:hex "#000000"} {:hex color}]})
|
||||
mark {:id :mark :kind :rect :z "a1"
|
||||
:channels {[:geom :size] (ch/framed 2)
|
||||
[:style :color] (ch/framed 1)}}
|
||||
instance (fn [id child z]
|
||||
{:id id :kind :instance :z z :source {:symbol child}})
|
||||
document {:fps 30 :width 20 :height 20
|
||||
:palettes {:day (palette :day "Day" "#000000" "#112233")
|
||||
:flash (palette :flash "Flash" "#ffffff" "#aabbcc")}
|
||||
:default-palette :day
|
||||
:symbols
|
||||
{:main {:id :main :frames 4
|
||||
:palette (ch/keyed {0 :day 2 :flash} :hold)
|
||||
:nodes {:inherited (instance :inherited :drawing "a1")
|
||||
:fixed (assoc (instance :fixed :fixed "a2")
|
||||
:palette (ch/framed :day))}}
|
||||
:drawing {:id :drawing :frames 4 :nodes {:mark mark}}
|
||||
:fixed {:id :fixed :frames 4 :palette (ch/framed :flash)
|
||||
:nodes {:mark mark}}}}
|
||||
context (pal/compile document)
|
||||
resolve (clip/resolver document :main nil context nil)
|
||||
colors #(mapv :color (resolve %))]
|
||||
(is (= [1 1] (colors 0)) "both children start in the day bank")
|
||||
(is (= [3 1] (colors 2))
|
||||
"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)))))
|
||||
[:style :color] (ch/framed 1)}}]
|
||||
{:fps 30 :width 20 :height 20
|
||||
:palettes {:day (palette :day "#112233") :night (palette :night "#aabbcc")
|
||||
:ink (palette :ink "#101010") :dusk (palette :dusk "#664422")}
|
||||
:default-palette :day
|
||||
:symbols
|
||||
{:main {:id :main :frames 6
|
||||
:nodes {:plain {:id :plain :kind :instance :z "a1" :source {:symbol :plain}}
|
||||
:face {:id :face :kind :instance :z "a2" :source {:symbol :face}
|
||||
:span [0 3] :time {:at 0}}}}
|
||||
:plain {:id :plain :frames 6 :nodes {:mark mark}}
|
||||
:face {:id :face :frames 6 :palette :night :nodes {:mark mark}}
|
||||
:lane {:id :lane :type :palette-track :display :lane :frames 6
|
||||
:nodes {:n {:id :n :kind :instance :z "a1" :source {:symbol :ink-palette}
|
||||
:span [0 1] :time {:at 1}}}}
|
||||
:ink-palette {:id :ink-palette :type :palette :palette-ref :ink :frames 1 :nodes {}}}}))
|
||||
|
||||
(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")
|
||||
;; The renderer clears with this exact resolver state before rasterising the
|
||||
;; returned ops, so a palette cut changes the stage background as well as
|
||||
;; authored shapes.
|
||||
(main 1)
|
||||
(is (= :night (clip/active-palette main)))
|
||||
(is (= (pal/render-index context :night 0)
|
||||
(pal/background-index context (clip/active-palette main))))))
|
||||
(defn- frame-of
|
||||
"What frame `f` of symbol `sid` draws, and the one palette it is in."
|
||||
[document sid f]
|
||||
(let [context (pal/compile document)
|
||||
r (clip/resolver document sid nil context nil)
|
||||
ops (vec (r f))]
|
||||
{:colors (mapv :color (remove #(#{:begin :end} (:kind %)) ops))
|
||||
:active (clip/active-palette r)
|
||||
:ramp (pal/effective-ramp context (clip/active-palette r))}))
|
||||
|
||||
(deftest a-frame-is-in-one-palette-and-the-shallowest-choice-wins
|
||||
(let [doc one-palette-doc]
|
||||
(is (= {:colors [1 1] :active :night}
|
||||
(select-keys (frame-of doc :main 0) [:colors :active]))
|
||||
"a face set to night turns ALL of main night while it is drawn; shapes keep their slot")
|
||||
(is (= :day (:active (frame-of doc :main 4)))
|
||||
"once the face is gone main is back in the project's palette")
|
||||
(is (= :day (:active (frame-of (assoc-in doc [:symbols :main :palette] :day) :main 0)))
|
||||
"a palette set on the open symbol beats anything inside it")
|
||||
(is (= :ink (:active (frame-of (assoc-in doc [:symbols :main :palette-track] :lane) :main 1)))
|
||||
"and so does the open symbol's palette lane")
|
||||
(is (= :dusk (:active (frame-of (assoc-in doc [:symbols :main :nodes :face :palette] :dusk) :main 0)))
|
||||
"an instance set to a palette stands in for the symbol's own")
|
||||
(is (= :ink (:active (frame-of (assoc-in doc [:symbols :face :palette-track] :lane) :main 1)))
|
||||
"a child's palette lane turns the whole frame, not just the child")
|
||||
(is (= :night (:active (frame-of doc :face 0)))
|
||||
"the face's own tab is in its palette")
|
||||
(is (= [[0 0 0] [170 187 204]] (:ramp (frame-of doc :main 0)))
|
||||
"the frame's colours are that one palette's and nothing else's")))
|
||||
|
||||
(deftest between-two-choices-at-one-depth-the-one-on-top-wins
|
||||
(let [doc (-> one-palette-doc
|
||||
(assoc-in [:symbols :plain :palette] :dusk))]
|
||||
(is (= :night (:active (frame-of doc :main 0))) "face is drawn over plain")
|
||||
(is (= :dusk (:active (frame-of doc :main 4))) "and without the face, plain's")))
|
||||
|
||||
(deftest an-inherit-end-of-a-blend-is-what-the-frame-is-in-without-it
|
||||
(let [choice (assoc (ch/keyed {0 pal/inherit 2 :ink} :linear) :semantic :palette)
|
||||
doc (-> one-palette-doc
|
||||
(assoc-in [:symbols :main :palette-track] :lane)
|
||||
(assoc-in [:symbols :lane :nodes :n]
|
||||
{:id :n :kind :instance :z "a1" :source {:symbol :ink-palette}
|
||||
:span [0 3] :time {:at 0} :channels {[:palette] choice}}))]
|
||||
(is (= {:from :night :to :ink :t 0.5} (:active (frame-of doc :main 1)))
|
||||
"main's lane blends from what the face makes the frame, to ink")))
|
||||
|
||||
(deftest the-palettes-a-tree-uses
|
||||
(let [doc (-> one-palette-doc
|
||||
(assoc-in [:symbols :main :nodes :plain :palette] :ink))]
|
||||
(is (= [{:palette :ink :sid :main :via :instance}
|
||||
{:palette :night :sid :face :via :symbol}]
|
||||
(clip/palette-uses doc :main)))))
|
||||
|
||||
(deftest unused-slots-are-emptied-in-place
|
||||
(let [p {:id :a :name "a"
|
||||
:slots [{:name :bg :hex "#000000"} {:hex "#111111"} {:name :teeth :hex "#222222"}
|
||||
{:hex "#333333"} {:hex "#444444"} {:hex "#000000"}]}
|
||||
mark (fn [id c] {:id id :kind :rect :z "a1" :channels {[:style :color] c}})
|
||||
nodes {:x (mark :x (ch/keyed {0 3 1 1} :hold))
|
||||
:y (mark :y (ch/framed [:remap {4 1}]))}
|
||||
used (pal/slots-used [{:nodes nodes}])]
|
||||
(is (= #{1 3 4} used) "every key counts, and both sides of a remap")
|
||||
(is (= [] (pal/emptyable p used))
|
||||
"the background, a named face tone and an already empty slot are left alone")
|
||||
(is (= [3] (pal/emptyable p #{1 4})))
|
||||
(is (= ["#000000" "#111111" "#222222" "#000000" "#444444" "#000000"]
|
||||
(mapv :hex (:slots (pal/empty-slots p [3]))))
|
||||
"emptied where it is, so no slot number moves")))
|
||||
|
||||
(deftest a-palette-lane-can-blend-between-keyed-palettes
|
||||
(let [palette (fn [id color]
|
||||
|
|
@ -531,8 +547,7 @@
|
|||
(clip/palette-at document nil :day (clip/symbol document :main) 2 nil))
|
||||
"the palette strip asks the same question the resolver answers: both ends of a blend")
|
||||
(is (= [128 128 128]
|
||||
(nth (pal/effective-ramp context (clip/active-palette resolve))
|
||||
(pal/render-index context :day 1))))
|
||||
(nth (pal/effective-ramp context (clip/active-palette resolve)) 1)))
|
||||
(is (nil? (:refused slid)) (:refused slid))
|
||||
(is (= [1 6] (node/placed-span
|
||||
(get-in slid [:clip :symbols :palettes :nodes :change]))))
|
||||
|
|
@ -569,8 +584,7 @@
|
|||
(resolve 2)
|
||||
(is (= {:from day :to night :t 0.5} (clip/active-palette resolve)))
|
||||
(is (= [128 128 128]
|
||||
(nth (pal/effective-ramp context (clip/active-palette resolve))
|
||||
(pal/render-index context day 1))))))
|
||||
(nth (pal/effective-ramp context (clip/active-palette resolve)) 1)))))
|
||||
(deftest a-knockout-makes-a-hole-in-its-own-symbol-only
|
||||
(let [sq (fn [x0 y0 x1 y1] [x0 y0 x1 y0 x1 y1 x0 y1])
|
||||
document
|
||||
|
|
@ -634,7 +648,7 @@
|
|||
ops (vec ((clip/resolver document :main nil context nil) 0))
|
||||
ras (raster/draw-ops! (raster/clear! (raster/make 320 200) 0) ops)
|
||||
at (fn [x y] (aget (:buf ras) (+ x (* y 320))))
|
||||
slot #(pal/render-index context (pal/default-palette-id document) %)]
|
||||
slot identity]
|
||||
(is (= (slot 5) (at 7 10)) "the wall under the beam is lit")
|
||||
(is (= (slot 3) (at 12 10)) "the door under it is a slot the map leaves alone")
|
||||
(is (= (slot 2) (at 30 10)) "and the wall outside it is as it was")
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@
|
|||
(let [ls (leaf/leaves :c1 @take/clip)
|
||||
n (get ls "clip/c1/symbol/face-1/node/mouth")]
|
||||
(is (= {:id :mouth :name "mouth" :kind :poly :parent :head
|
||||
:z "a1" :pose-group :mouth} n))
|
||||
:z "a1" :time {:offset 4} :pose-group :mouth} n))
|
||||
(is (nil? (:channels n)))
|
||||
(is (:animated? (get ls "clip/c1/symbol/face-1/channel/mouth/geom.pts")))))
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,8 @@
|
|||
(is (= [15 60 640 360 :arthur/pico-8]
|
||||
[(:fps doc) (clip/frames doc :main) (:width doc) (:height doc) (:default-palette doc)]))
|
||||
(is (every? pal/valid-palette? (vals (:palettes doc))))
|
||||
(is (= (count pal/presets) (count (:palettes doc))))))
|
||||
(is (= [:arthur/pico-8] (keys (:palettes doc)))
|
||||
"a project carries the palette it draws with, not the whole shelf")))
|
||||
(testing "a drawing made in a nested lane is one project frame long"
|
||||
;; The bug that started this: a lane made at 30 in a project then set to
|
||||
;; 12 got drawings a thirtieth of a second long, which the output either
|
||||
|
|
|
|||
|
|
@ -98,7 +98,9 @@
|
|||
(is (= [:mouth :head :place] (symbol/lineage (:nodes @sym*) :mouth)))
|
||||
(is (= [:mouth-in :mouth :head :place] (symbol/lineage (:nodes @sym*) :mouth-in)))
|
||||
(is (= {:mode :map :expose 2} (:time (node :root))))
|
||||
(is (every? #(nil? (:time (node %))) [:place :head :mouth :mouth-in])))
|
||||
;; The mouth leads, 125ms at the take's 30fps; its interior inherits that.
|
||||
(is (= {:offset 4} (:time (node :mouth))))
|
||||
(is (every? #(nil? (:time (node %))) [:place :head :mouth-in])))
|
||||
|
||||
(deftest geometry-is-flat-and-dense-and-the-interior-shares-the-outline-s-block
|
||||
(doseq [id [:mouth :mouth-in]]
|
||||
|
|
@ -204,7 +206,9 @@
|
|||
res (clip/resolver c :main @store pal/index-of nil)
|
||||
k (first (:value (chan :place [:xform :scale])))
|
||||
pos (:value (chan :place [:xform :pos]))
|
||||
tfs (:transforms @take/measured)]
|
||||
tfs (:transforms @take/measured)
|
||||
lead (get-in c [:symbols :face-1 :nodes :mouth :time :offset] 0)]
|
||||
(is (pos? lead) "a frozen mouth leads by default")
|
||||
(doseq [f (range 0 take/frames 13)]
|
||||
(let [ops (res f)
|
||||
op (first (filter #(= [:face-1 :mouth] (:node %)) ops))
|
||||
|
|
@ -216,7 +220,9 @@
|
|||
ef (node/expose f 2)
|
||||
;; The frozen, quantised vertex — so the fixed point is not part of
|
||||
;; what is being asserted here; it has its own test.
|
||||
flat (pts-at :mouth ef)
|
||||
;; The mouth LEADS: its pose is read `lead` frames ahead of the
|
||||
;; head it hangs off, held at the last frame. See `freeze/mouth-lead`.
|
||||
flat (pts-at :mouth (min (dec take/frames) (+ ef lead)))
|
||||
g {:x (nth flat 0) :y (nth flat 1)}
|
||||
;; Where the anchor fit says that head-local point was in the image:
|
||||
;; the fit removed the head's motion, so putting it back is the fit's
|
||||
|
|
|
|||
|
|
@ -101,7 +101,9 @@
|
|||
cut (pose/put-cut clip :main :face-2 :mouth 0 20)
|
||||
original (by-node clip store 4)
|
||||
held (by-node cut store 4)
|
||||
source (by-node clip store 20)]
|
||||
;; Uncut, frame f shows pose f + lead, so pose 20 is on frame 20 − lead.
|
||||
lead (get-in clip [:symbols :face-2 :nodes :mouth :time :offset] 0)
|
||||
source (by-node clip store (- 20 lead))]
|
||||
(is (empty? (clip/problems cut)))
|
||||
(is (= (get held [:face-2 :mouth]) (get source [:face-2 :mouth])))
|
||||
(is (not= (get held [:face-2 :mouth]) (get original [:face-2 :mouth])))
|
||||
|
|
|
|||
|
|
@ -619,7 +619,7 @@ async function main() {
|
|||
const stageLoaded = await statusMatching(/loaded 8625 stage study/, 160);
|
||||
check(stageLoaded !== null, 'the 8625 stage is ready', stageLoaded ?? (await page.eval(STATUS)));
|
||||
const eyeSelected = await page.eval(`(() => {
|
||||
const select = document.querySelector('.params .section:last-child select');
|
||||
const select = [...document.querySelectorAll('.params .section')].find(s => s.querySelector('h2')?.textContent === 'tracking')?.querySelector('select');
|
||||
// Settings belong to tracked features shared by the stage placements.
|
||||
const option = [...select.options]
|
||||
.find(o => o.textContent.trim().endsWith('feature · face-1/eye-r'));
|
||||
|
|
@ -663,7 +663,7 @@ async function main() {
|
|||
await page.eval(CLICK('pause'));
|
||||
}
|
||||
const subjectSelected = await page.eval(`(() => {
|
||||
const select = document.querySelector('.params .section:last-child select');
|
||||
const select = [...document.querySelectorAll('.params .section')].find(s => s.querySelector('h2')?.textContent === 'tracking')?.querySelector('select');
|
||||
const option = [...select.options]
|
||||
.find(o => o.textContent.includes('subject · face-1'));
|
||||
if (!option) return false;
|
||||
|
|
@ -712,7 +712,7 @@ async function main() {
|
|||
}
|
||||
}
|
||||
const teethSelected = await page.eval(`(() => {
|
||||
const select = document.querySelector('.params .section:last-child select');
|
||||
const select = [...document.querySelectorAll('.params .section')].find(s => s.querySelector('h2')?.textContent === 'tracking')?.querySelector('select');
|
||||
const option = [...select.options]
|
||||
.find(o => o.textContent.trim().endsWith('feature · face-1/teeth'));
|
||||
if (!option) return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue