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
|
|
@ -436,8 +436,8 @@ class DocumentTests(TestCase):
|
|||
self.assertEqual(200, self.save(leaves).status_code)
|
||||
rows = self.client.get("/api/symbols").json()["palettes"]
|
||||
self.assertEqual(
|
||||
[("Moonlit", "night", "c1")],
|
||||
[(r["name"], r["palette"], r["cid"]) for r in rows],
|
||||
[("Moonlit", "night", "c1", ["#001122"])],
|
||||
[(r["name"], r["palette"], r["cid"], r["hexes"]) for r in rows],
|
||||
)
|
||||
|
||||
def test_a_document_comes_back_exactly(self):
|
||||
|
|
|
|||
|
|
@ -413,6 +413,26 @@ def footage_list(request):
|
|||
|
||||
_SYMBOL_LEAF = re.compile(r"^clip/([^/]+)/symbol/([^/]+)$")
|
||||
_PALETTE_LEAF = re.compile(r"^clip/([^/]+)/palette/([^/]+)$")
|
||||
_HEX = re.compile(r"#[0-9a-fA-F]{6}")
|
||||
|
||||
|
||||
def _slot_hexes(value):
|
||||
"""A palette leaf's slot colours, in order. Every slot carries exactly one
|
||||
hex, so they are read off whatever follows `:slots` without decoding
|
||||
transit's caches."""
|
||||
if not isinstance(value, list) or "~:slots" not in value:
|
||||
return []
|
||||
out = []
|
||||
|
||||
def walk(x):
|
||||
if isinstance(x, list):
|
||||
for y in x:
|
||||
walk(y)
|
||||
elif isinstance(x, str) and _HEX.fullmatch(x):
|
||||
out.append(x.lower())
|
||||
|
||||
walk(value[value.index("~:slots") + 1])
|
||||
return out
|
||||
|
||||
|
||||
def _transit_fields(value, *keys):
|
||||
|
|
@ -459,6 +479,9 @@ def symbols(request):
|
|||
"cid": m.group(1),
|
||||
"palette": m.group(2),
|
||||
"name": fields.get("name") or m.group(2).replace("~", "/"),
|
||||
# Every slot carries exactly one hex, in order, so the strip is
|
||||
# read off the value without decoding transit's caches.
|
||||
"hexes": _slot_hexes(leaf.value),
|
||||
})
|
||||
palettes.sort(key=lambda r: (r["project_name"], r["project"], r["name"]))
|
||||
return JsonResponse({"symbols": rows, "palettes": palettes})
|
||||
|
|
|
|||
|
|
@ -188,17 +188,18 @@
|
|||
and the swarm carry no `:subjects` — so every reader already reads absence as
|
||||
none, and `clip-keys` says which fields MAY be here, not which must.
|
||||
|
||||
`settings` overrides any of `blank-settings`. It starts with every one of
|
||||
`palette/presets`, and `:palette` is the id of the one it draws with."
|
||||
`settings` overrides any of `blank-settings`. `:palette` names the preset it
|
||||
draws with, and that one is the project's only palette until more are added."
|
||||
([] (blank {}))
|
||||
([settings]
|
||||
(let [{:keys [fps seconds width height palette] :as s} (merge blank-settings (into {} (remove (comp nil? val)) settings))
|
||||
presets (into {} (map (juxt :id identity)) pal/presets)]
|
||||
presets (into {} (map (juxt :id identity)) pal/presets)
|
||||
palette (if (contains? presets palette) palette pal/default-id)]
|
||||
{:name (:name s)
|
||||
:fps fps
|
||||
:width width :height height
|
||||
:palettes presets
|
||||
:default-palette (if (contains? presets palette) palette pal/default-id)
|
||||
:palettes (select-keys presets [palette])
|
||||
:default-palette palette
|
||||
:root :main
|
||||
:symbols {:main {:id :main :frames (max 1 (js/Math.round (* seconds fps))) :nodes {}}}})))
|
||||
|
||||
|
|
@ -306,80 +307,115 @@
|
|||
(ch/value-at selection frame store)
|
||||
:else selection))
|
||||
|
||||
(defn palette-at
|
||||
"The palette symbol `owner` draws in at `frame`, as the stage's root does: a
|
||||
palette id, or `{:from :to :t}` while its palette lane blends from one to the
|
||||
next. `inherited` is what an unset palette falls back to, then `default`."
|
||||
[clip store default owner frame inherited]
|
||||
;; A palette track has meaningful uncovered time. Ordinary held
|
||||
;; channels clamp to their first key before it, but doing that
|
||||
;; here would erase the gap before the first palette segment.
|
||||
(let [channel-value (partial channel-value store)
|
||||
fallback (or (channel-value (:palette owner) frame)
|
||||
inherited default)
|
||||
materialize (fn [choice]
|
||||
(cond
|
||||
(= pal/inherit choice) fallback
|
||||
(map? choice) (-> choice
|
||||
(update :from #(if (= pal/inherit %) fallback %))
|
||||
(update :to #(if (= pal/inherit %) fallback %)))
|
||||
:else choice))
|
||||
track (:palette-channel owner)
|
||||
track-value (if-let [ks (:keys track)]
|
||||
(some->> (keys ks)
|
||||
(filter #(<= % frame))
|
||||
sort last
|
||||
(get ks))
|
||||
(channel-value track frame))]
|
||||
(or (when-let [track-sid (and (keyword? (:palette-track owner))
|
||||
(:palette-track owner))]
|
||||
(let [track-symbol (symbol clip track-sid)
|
||||
palette-clip (first
|
||||
(defn- own-palette
|
||||
"The palette symbol `owner` itself chooses at `frame`, or nil when it chooses
|
||||
none and takes what it is in: its palette lane where a segment covers the
|
||||
frame, else its own `:palette` (which an instance's palette stands in for).
|
||||
A lane's `inherit` end means the symbol's own palette when it has one, and
|
||||
stays `inherit` — whatever the frame is in without this lane — when not.
|
||||
A palette lane has meaningful uncovered time: ordinary held channels clamp to
|
||||
their first key before it, which here would erase the gap before the first
|
||||
segment."
|
||||
[clip store owner frame]
|
||||
(let [own (channel-value store (:palette owner) frame)
|
||||
fill #(if (and own (= pal/inherit %)) own %)
|
||||
settle (fn [choice] (if (map? choice) (-> choice (update :from fill) (update :to fill)) (fill choice)))
|
||||
track (:palette-channel owner)]
|
||||
(or (when-let [track-symbol (some->> (:palette-track owner) (symbol clip))]
|
||||
(let [palette-clip (first
|
||||
(filter (fn [n]
|
||||
(let [[a b] (node/placed-span n)]
|
||||
(and a (<= a frame) (< frame b))))
|
||||
(symbol/children (:nodes track-symbol))))
|
||||
palette-symbol (some-> palette-clip node/source
|
||||
(#(symbol clip %)))
|
||||
fallback (when (= :palette (:type palette-symbol))
|
||||
(:palette-ref palette-symbol))
|
||||
palette-symbol (some-> palette-clip node/source (#(symbol clip %)))
|
||||
choice (get-in palette-clip [:channels [:palette]])
|
||||
start (some-> palette-clip node/placed-span first)]
|
||||
(or (when (and choice start)
|
||||
(materialize (channel-value choice (- frame start))))
|
||||
fallback)))
|
||||
track-value
|
||||
fallback)))
|
||||
(settle (channel-value store choice (- frame start))))
|
||||
(when (= :palette (:type palette-symbol))
|
||||
(:palette-ref palette-symbol)))))
|
||||
(if-let [ks (:keys track)]
|
||||
(some->> (keys ks) (filter #(<= % frame)) sort last (get ks))
|
||||
(channel-value store track frame))
|
||||
own)))
|
||||
|
||||
(defn- settle
|
||||
"`choice` with an `inherit` end standing for `under`, what the frame would be
|
||||
in without it."
|
||||
[choice under]
|
||||
(let [under (if (map? under) (:from under) under)
|
||||
fill #(if (= pal/inherit %) under %)]
|
||||
(cond
|
||||
(nil? choice) under
|
||||
(map? choice) (-> choice (update :from fill) (update :to fill))
|
||||
:else (fill choice))))
|
||||
|
||||
(defn palette-at
|
||||
"The palette symbol `owner` chooses at `frame`, with what it does not choose
|
||||
standing for `inherited`, then `default`: an id, or `{:from :to :t}` while
|
||||
its palette lane blends."
|
||||
[clip store default owner frame inherited]
|
||||
(settle (own-palette clip store owner frame) (or inherited default)))
|
||||
|
||||
(defn frame-palette
|
||||
"THE ONE PALETTE A FRAME IS IN, from what each symbol drawn in it chooses:
|
||||
`choices` is `[depth choice]` in draw order, the open symbol at depth 0.
|
||||
The SHALLOWEST choice wins — a palette set on the open symbol overrides
|
||||
anything inside it — and between two at one depth the one drawn last, on
|
||||
top. What the winner leaves to `inherit` is the next choice down, and under
|
||||
them all the project's."
|
||||
[default choices]
|
||||
(reduce (fn [under [_ choice]] (settle choice under))
|
||||
default
|
||||
;; Deepest first, so the shallowest settles last; `sort-by` is
|
||||
;; stable, so at one depth the one drawn last does.
|
||||
(sort-by (comp - first) choices)))
|
||||
|
||||
(defn palette-uses
|
||||
"Every palette symbol `sid` and what it places choose, and where:
|
||||
`{:palette :sid :via}`, `:via` being `:symbol` for a symbol's own, `:lane` for
|
||||
its palette lane and `:instance` for an instance set to one. Outermost first,
|
||||
each once. A palette nothing chooses is the one inherited, so is not here."
|
||||
[clip sid]
|
||||
(loop [todo [sid] seen #{} out []]
|
||||
(if-let [s (first todo)]
|
||||
(if (contains? seen s)
|
||||
(recur (rest todo) seen out)
|
||||
(let [sym (symbol clip s)
|
||||
lane (symbol clip (:palette-track sym))
|
||||
use (fn [via x] (map (fn [p] {:palette p :sid s :via via}) (pal/choices x)))
|
||||
nodes (vals (:nodes sym))]
|
||||
(recur (concat (rest todo) (mapcat node/sources (filter #(= :instance (:kind %)) nodes)))
|
||||
(conj seen s)
|
||||
(into out (distinct)
|
||||
(concat (use :symbol (:palette sym))
|
||||
(use :lane (:palette-channel sym))
|
||||
(mapcat (fn [n]
|
||||
(concat (use :lane (:palette-ref (some->> (node/source n) (symbol clip))))
|
||||
(use :lane (get-in n [:channels [:palette]]))))
|
||||
(vals (:nodes lane)))
|
||||
(mapcat #(use :instance (:palette %)) nodes))))))
|
||||
(vec (distinct out)))))
|
||||
|
||||
(defn resolver
|
||||
"Resolve an output frame, selecting native content at each symbol boundary.
|
||||
Every instance owns its cursors and buffers. The IResolver queries return
|
||||
native node frames and world matrices for the last rendered output frame."
|
||||
[clip sid store palette opts]
|
||||
(let [context? (and (map? palette) (:palettes palette) (:offsets palette))
|
||||
active-palette-state (atom (:default palette))]
|
||||
(letfn [(root-selection-at [owner frame inherited]
|
||||
(palette-at clip store (:default palette) owner frame inherited))
|
||||
(selection-at [owner frame inherited]
|
||||
(let [selection (:palette owner)
|
||||
chosen (cond
|
||||
(nil? selection) nil
|
||||
(and (map? selection) (contains? selection :animated?))
|
||||
(ch/value-at selection frame store)
|
||||
:else selection)]
|
||||
(or chosen inherited (:default palette))))
|
||||
(build [sid chain pose-tracks root?]
|
||||
(let [context? (and (map? palette) (contains? palette :palettes))
|
||||
active-palette-state (atom (:default palette))
|
||||
;; What each symbol drawn this frame chooses, as `[depth choice]`.
|
||||
chosen (volatile! [])]
|
||||
(letfn [(build [sid chain pose-tracks root?]
|
||||
(when (some #{sid} chain)
|
||||
(throw (ex-info "symbol cycle" {:chain (conj chain sid)})))
|
||||
(let [sym (or (symbol clip sid)
|
||||
(throw (ex-info "an instance names a missing symbol" {:symbol sid})))
|
||||
active (volatile! (when context? (:default palette)))
|
||||
depth (count chain)
|
||||
nodes (:nodes sym)
|
||||
rank (symbol/draw-rank nodes (symbol/order nodes))
|
||||
ids (sort-by rank (keys nodes))
|
||||
own (symbol/resolver sym store (if context?
|
||||
#(pal/render-index palette @active %)
|
||||
palette)
|
||||
own (symbol/resolver sym store (if context? pal/slot palette)
|
||||
(assoc opts :pose-tracks pose-tracks))
|
||||
;; Each cel owns its source resolver and mutable buffers. A
|
||||
;; tracing symbol has nothing to resolve: it is one op.
|
||||
|
|
@ -399,16 +435,18 @@
|
|||
;; A symbol that knocks out is drawn into a layer of its own,
|
||||
;; so what it clears is only ever its own.
|
||||
layered? (symbol/knocks? nodes)
|
||||
step (fn [f pre inherited forced]
|
||||
;; Each symbol drawn says which palette it chooses, if any;
|
||||
;; the root, once all are drawn, makes the frame's ONE
|
||||
;; palette of them. Shapes draw slots, so nothing drawn
|
||||
;; depends on which. An instance's palette stands in for the
|
||||
;; symbol's own, so its lane still plays.
|
||||
step (fn [f pre override]
|
||||
(when root? (vreset! chosen []))
|
||||
(when context?
|
||||
(vreset! active (or forced
|
||||
(if root?
|
||||
(root-selection-at sym (js/Math.floor f) inherited)
|
||||
inherited)
|
||||
(:default palette))))
|
||||
;; The same decision that maps local drawing slots to
|
||||
;; the active bank also names the clear colour.
|
||||
(when root? (reset! active-palette-state @active))
|
||||
(when-let [c (own-palette clip store
|
||||
(cond-> sym override (assoc :palette override))
|
||||
(js/Math.floor f))]
|
||||
(vswap! chosen conj [depth c])))
|
||||
(vreset! entered {})
|
||||
(let [by-id (into {} (map (juxt :node identity))
|
||||
(own (js/Math.floor f) (js/Math.floor pre)))]
|
||||
|
|
@ -450,17 +488,15 @@
|
|||
(or (:frame (when (number? prior)
|
||||
(placed-frame clip n prior)))
|
||||
(dec frame))
|
||||
@active
|
||||
(when (and context? (:palette n))
|
||||
(selection-at n frame nil)))))))
|
||||
(:palette n))))))
|
||||
(when-let [op (get by-id id)] [op]))))
|
||||
ids))
|
||||
layered? (conj {:kind :end :node []}))))]
|
||||
(reify
|
||||
IFn
|
||||
(-invoke [_ f] (step f (dec f) nil nil))
|
||||
(-invoke [_ f pre] (step f pre nil nil))
|
||||
(-invoke [_ f pre inherited forced] (step f pre inherited forced))
|
||||
(-invoke [_ f] (step f (dec f) nil))
|
||||
(-invoke [_ f pre] (step f pre nil))
|
||||
(-invoke [_ f pre override] (step f pre override))
|
||||
symbol/IResolver
|
||||
(world-of [_ [id & more]]
|
||||
(if more
|
||||
|
|
@ -484,7 +520,11 @@
|
|||
IFn
|
||||
;; `pre` is the frame before, so a child placed at a speed is handed
|
||||
;; the interval `(pre, f]` its preserve-snap may reach back into.
|
||||
(-invoke [_ f] (r f (dec f) (when context? (:default palette)) nil))
|
||||
(-invoke [_ f]
|
||||
(let [ops (r f (dec f))]
|
||||
(when context?
|
||||
(reset! active-palette-state (frame-palette (:default palette) @chosen)))
|
||||
ops))
|
||||
symbol/IResolver
|
||||
(world-of [_ path] (symbol/world-of r path))
|
||||
(frame-of [_ path] (symbol/frame-of r path))
|
||||
|
|
|
|||
|
|
@ -64,10 +64,30 @@
|
|||
free)})
|
||||
|
||||
(def presets
|
||||
"Palettes a new project starts with, borrowed from worlds that already work
|
||||
in sixteen colours or fewer. Only the one a project draws with costs it
|
||||
anything; the rest are there to switch to."
|
||||
"Palettes borrowed from worlds that already work in sixteen colours or fewer:
|
||||
a shelf to start a project from or add to one, kept out of the project until
|
||||
then. A sixteen-colour machine's palette is all sixteen of its colours, each
|
||||
once, the face tones picked from them; a four-colour one repeats, and a face
|
||||
in it reads by value alone, as on a Game Boy."
|
||||
[default-palette
|
||||
;; The sixteen colours of the IBM PC's text modes, which VGA kept from EGA
|
||||
;; and CGA: the DOS blue behind, the light red and brown every EGA face was.
|
||||
(preset :arthur/vga "VGA"
|
||||
["#0000aa" "#ff5555" "#aa5500" "#aa0000" "#ffffff" "#aaaaaa" "#00aaaa" "#000000" "#555555"]
|
||||
["#00aa00" "#aa00aa" "#55ff55" "#55ffff" "#ff55ff" "#ffff55" "#5555ff"])
|
||||
;; The Commodore 64's VIC-II as Pepto measured it, on its own blue screen.
|
||||
(preset :arthur/c64 "Commodore 64"
|
||||
["#352879" "#9a6759" "#6f4f25" "#68372b" "#ffffff" "#959595" "#70a4b2" "#000000" "#433900"]
|
||||
["#6f3d86" "#588d43" "#b8c76f" "#444444" "#6c6c6c" "#9ad284" "#6c5eb5"])
|
||||
;; CGA's four-colour mode, palette 1 at high intensity: magenta skin shaded
|
||||
;; in cyan, as it was.
|
||||
(preset :arthur/cga "CGA"
|
||||
["#000000" "#ff55ff" "#55ffff" "#000000" "#ffffff" "#ffffff" "#55ffff" "#000000" "#000000"]
|
||||
["#ff55ff" "#55ffff" "#ffffff" "#000000" "#ff55ff" "#55ffff" "#ffffff"])
|
||||
;; The Amiga's Workbench 1.3: four colours, blue, white, black and orange.
|
||||
(preset :arthur/workbench "Workbench 1.3"
|
||||
["#0055aa" "#ff8800" "#000022" "#000022" "#ffffff" "#ffffff" "#0055aa" "#000022" "#000022"]
|
||||
["#0055aa" "#ffffff" "#000022" "#ff8800" "#0055aa" "#ffffff" "#ff8800"])
|
||||
;; Lexaloffle's PICO-8, all sixteen, its peach and brown as the skin ramp.
|
||||
(preset :arthur/pico-8 "PICO-8"
|
||||
["#1d2b53" "#ffccaa" "#ab5236" "#7e2553" "#fff1e8" "#c2c3c7" "#29adff" "#000000" "#5f574f"]
|
||||
|
|
@ -99,89 +119,133 @@
|
|||
(when (contains? ps default-id) default-id)
|
||||
(first (sort-by str (keys ps))))))
|
||||
|
||||
(defn- slot-index [p value]
|
||||
(cond
|
||||
(and (integer? value) (<= 0 value) (< value (count (:slots p)))) value
|
||||
;; Compatibility for existing documents. New drawing data is numeric.
|
||||
(keyword? value) (first (keep-indexed #(when (= value (:name %2)) %1) (:slots p)))
|
||||
:else nil))
|
||||
;; ONE PALETTE PER FRAME
|
||||
;;
|
||||
;; A frame is drawn in exactly one palette, or one blend of two while a palette
|
||||
;; lane tweens. Drawing data stores slot numbers, so the raster index IS the
|
||||
;; slot, and the palette is only the ramp the raster is expanded through. Which
|
||||
;; palette a frame is in is decided by the open symbol's tree; see
|
||||
;; `clip/resolver`.
|
||||
|
||||
(defn compile
|
||||
"Compile the project's palette assets into the one ramp used by the raster.
|
||||
Index 255 remains the conspicuous bad-data sentinel."
|
||||
[clip]
|
||||
(let [selection-values (fn [x]
|
||||
(def bg-slot
|
||||
"Slot zero is what a frame is cleared to, in whichever palette it is in."
|
||||
0)
|
||||
|
||||
(defn slot
|
||||
"A shape's colour as a raster index: its slot number, or a legacy tone
|
||||
keyword's place in `entries`. Anything else is 255, the conspicuous
|
||||
bad-data sentinel, which the ramp has no colour for and so shows MAGENTA."
|
||||
[value]
|
||||
(cond
|
||||
(and (integer? value) (<= 0 value) (< value 255)) value
|
||||
;; Compatibility for existing documents. New drawing data is numeric.
|
||||
(keyword? value) (get index-of value 255)
|
||||
:else 255))
|
||||
|
||||
(defn choices
|
||||
"The palette ids a palette setting can name: the one it holds, or each its
|
||||
keys do. `inherit` is not one."
|
||||
[x]
|
||||
(remove #(= inherit %)
|
||||
(cond
|
||||
(nil? x) []
|
||||
(and (map? x) (:keys x)) (vals (:keys x))
|
||||
(and (map? x) (contains? x :value)) [(:value x)]
|
||||
:else [x]))
|
||||
used (into #{(default-palette-id clip)}
|
||||
(mapcat selection-values)
|
||||
(concat (map :palette (vals (:symbols clip)))
|
||||
(map :palette-channel (vals (:symbols clip)))
|
||||
(map (fn [sym]
|
||||
(when (= :palette (:type sym)) (:palette-ref sym)))
|
||||
(vals (:symbols clip)))
|
||||
(for [sym (vals (:symbols clip))
|
||||
n (vals (:nodes sym))]
|
||||
(:palette n))
|
||||
(for [sym (vals (:symbols clip))
|
||||
n (vals (:nodes sym))]
|
||||
(get-in n [:channels [:palette]]))))
|
||||
ps (select-keys (palettes clip) used)
|
||||
ordered (sort-by (comp str key) ps)
|
||||
offsets (loop [xs ordered at 0 out {}]
|
||||
(if-let [[id p] (first xs)]
|
||||
(recur (next xs) (+ at (count (:slots p))) (assoc out id at))
|
||||
out))
|
||||
total (reduce + (map #(count (:slots (val %))) ordered))]
|
||||
(when (> total 255)
|
||||
(throw (ex-info "palettes visible in one render use more than 255 slots"
|
||||
{:slots total :palettes (count ps)})))
|
||||
{:palettes ps
|
||||
:default (default-palette-id clip)
|
||||
:offsets offsets
|
||||
:ramp (vec (mapcat (fn [[_ p]] (map #(hex->rgb (:hex %)) (:slots p))) ordered))
|
||||
:bg (get offsets (default-palette-id clip) 0)}))
|
||||
:else [x])))
|
||||
|
||||
(defn render-index
|
||||
"A local slot (or a legacy tone keyword) in palette `id` -> raster index."
|
||||
[{:keys [palettes offsets]} id value]
|
||||
(let [id (if (map? id) (:from id) id)
|
||||
p (get palettes id)
|
||||
i (and p (slot-index p value))]
|
||||
(if (some? i) (+ (get offsets id 0) i) 255)))
|
||||
(defn compile
|
||||
"The project's palettes and the one a frame falls back to, for a renderer."
|
||||
[clip]
|
||||
{:palettes (palettes clip)
|
||||
:default (default-palette-id clip)})
|
||||
|
||||
(defn background-index
|
||||
"The raster index of slot zero in the resolver's active palette.
|
||||
|
||||
`index-of` remains a supported legacy palette map for domain callers; it has
|
||||
no palette banks or active selection, so its established `:bg` index applies."
|
||||
[palette active]
|
||||
(if (and (:palettes palette) (:offsets palette))
|
||||
(render-index palette active 0)
|
||||
(get palette :bg 0)))
|
||||
(defn ramp-of
|
||||
"A strip of hex colours as the ramp a raster is expanded through."
|
||||
[hexes]
|
||||
(mapv hex->rgb hexes))
|
||||
|
||||
(defn effective-ramp
|
||||
"The compiled ramp with the active palette blend applied. A hold returns the
|
||||
original vector; a linear palette segment rewrites only the left palette's
|
||||
bank, which is the bank the indexed raster was drawn into."
|
||||
[{:keys [palettes offsets ramp]} active]
|
||||
"The ramp of the active palette: an id, or `{:from :to :t}` while a palette
|
||||
lane blends, which is one pseudopalette mixed slot by slot. A slot only one
|
||||
end has keeps its colour."
|
||||
[{:keys [palettes default]} active]
|
||||
(let [ramp #(ramp-of (map :hex (:slots (get palettes %))))]
|
||||
(if-let [{:keys [from to t]} (when (map? active) active)]
|
||||
(let [a (get palettes from)
|
||||
b (get palettes to)
|
||||
at (get offsets from)
|
||||
n (min (count (:slots a)) (count (:slots b)))]
|
||||
(if (and a b (number? at) (number? t))
|
||||
(reduce (fn [out i]
|
||||
(let [x (hex->rgb (get-in a [:slots i :hex]))
|
||||
y (hex->rgb (get-in b [:slots i :hex]))]
|
||||
(assoc out (+ at i)
|
||||
(mapv #(js/Math.round (+ %1 (* t (- %2 %1)))) x y))))
|
||||
ramp (range n))
|
||||
ramp))
|
||||
ramp))
|
||||
(let [a (ramp from) b (ramp to)]
|
||||
(if (number? t)
|
||||
(into (mapv (fn [x y] (mapv #(js/Math.round (+ %1 (* t (- %2 %1)))) x y)) a b)
|
||||
(drop (count b) a))
|
||||
a))
|
||||
(ramp (if (contains? palettes active) active default)))))
|
||||
|
||||
(defn solo-ramp
|
||||
"`ramp` with every slot but `shown` faded most of the way to the background,
|
||||
so what is drawn in `shown` is all that stands out."
|
||||
[ramp shown]
|
||||
(let [bg (get ramp bg-slot [0 0 0])
|
||||
fade (fn [c] (mapv (fn [x b] (js/Math.round (+ b (* 0.2 (- x b))))) c bg))]
|
||||
(into [] (map-indexed (fn [i c] (if (= i shown) c (fade c)))) ramp)))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; which slots drawing uses
|
||||
;;
|
||||
;; A slot number means the same place in EVERY palette — that is what lets one
|
||||
;; drawing be shown in any of them — so a slot is in use when any shape names
|
||||
;; it, whichever palette it is seen in.
|
||||
|
||||
(defn- colour-slots
|
||||
"The slots a colour channel names at any key: a slot, a legacy tone, or both
|
||||
sides of a remap's map. A knockout names none."
|
||||
[ch]
|
||||
(let [values (if (:keys ch) (vals (:keys ch)) [(:value ch)])]
|
||||
(into #{}
|
||||
(comp (mapcat (fn [v]
|
||||
(cond
|
||||
(and (vector? v) (= :remap (first v))) (mapcat identity (second v))
|
||||
(= :clear v) []
|
||||
:else [v])))
|
||||
(map slot)
|
||||
(remove #{255}))
|
||||
values)))
|
||||
|
||||
(defn slots-used
|
||||
"Every slot a shape in `symbols` names."
|
||||
[symbols]
|
||||
(into #{}
|
||||
(mapcat #(some-> (get-in % [:channels [:style :color]]) colour-slots))
|
||||
(mapcat (comp vals :nodes) symbols)))
|
||||
|
||||
(def empty-slot
|
||||
"A slot with nothing in it: black, unnamed, as a new palette's free ones are."
|
||||
{:hex "#000000"})
|
||||
|
||||
(defn emptyable
|
||||
"The slots of palette `p` that can be emptied: none of `used` names them, and
|
||||
they are not already empty. Slot zero is the background, and a NAMED slot is
|
||||
a face tone measurement draws in whether or not anything uses it yet."
|
||||
[p used]
|
||||
(into []
|
||||
(keep-indexed (fn [i s] (when-not (or (contains? used i) (= bg-slot i) (:name s)
|
||||
(= empty-slot (select-keys s [:hex :name])))
|
||||
i)))
|
||||
(:slots p)))
|
||||
|
||||
(defn empty-slots
|
||||
"Palette `p` with slots `is` emptied. They stay where they are, so no
|
||||
drawing's slot number changes and the palette keeps its size."
|
||||
[p is]
|
||||
(reduce #(assoc-in %1 [:slots %2] empty-slot) p is))
|
||||
|
||||
(defn hexes-of [p] (mapv :hex (:slots p)))
|
||||
|
||||
(defn from-hexes
|
||||
"A palette asset from a strip of colours, its slots named as `entries` are so
|
||||
a legacy tone keyword still finds its slot."
|
||||
[id label hexes]
|
||||
{:id id :name label
|
||||
:slots (into (mapv (fn [e hex] {:name (:name e) :hex hex}) entries hexes)
|
||||
(map (fn [hex] {:hex hex}))
|
||||
(drop (count entries) hexes))})
|
||||
|
||||
(defn valid-palette? [{:keys [id name slots]}]
|
||||
(and id (string? name) (seq name) (vector? slots) (pos? (count slots))
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@
|
|||
;; through. Read here rather than in the fx so that the effect
|
||||
;; takes data and nothing else.
|
||||
:palette (pal/compile (:clip entry))
|
||||
:ramp (:ramp (pal/compile (:clip entry)))
|
||||
:ramp (let [p (pal/compile (:clip entry))] (pal/effective-ramp p (:default p)))
|
||||
:zoom zoom
|
||||
:audio-url (:audio entry)
|
||||
:name (stem (:label entry)
|
||||
|
|
|
|||
|
|
@ -252,3 +252,8 @@
|
|||
:else (let [i (.indexOf tabs sid)]
|
||||
{:db (assoc-in db [:ui :tabs] left)
|
||||
:dispatch [::open-symbol (get left (min i (dec (count left))))]})))))
|
||||
|
||||
(rf/reg-event-db
|
||||
::frame-palette
|
||||
;; Written by the player as it paints: see `subs.render/frame-palette`.
|
||||
(fn [db [_ active]] (assoc-in db [:ui :frame-palette (get-in db [:ui :open])] active)))
|
||||
|
|
|
|||
|
|
@ -162,6 +162,12 @@
|
|||
:host (get-in db [:ui :open]) :frame frame :point point
|
||||
:target target)}))
|
||||
|
||||
(defn choose-palette
|
||||
"Show palette `id` in the open tab's palette grid, rather than the one the
|
||||
tab draws in. Each tab keeps its own."
|
||||
[db id]
|
||||
(assoc-in db [:ui :palette (get-in db [:ui :open])] id))
|
||||
|
||||
(rf/reg-event-fx
|
||||
::import-palette
|
||||
(fn [{:keys [db]} [_ {:keys [project cid palette name]}]]
|
||||
|
|
@ -187,7 +193,7 @@
|
|||
(let [id (random-uuid)]
|
||||
(-> (edit/edit db #(assoc-in % [:palettes id]
|
||||
(assoc palette :id id :name (str (:name palette) " copy"))))
|
||||
(assoc-in [:ui :palette] id)
|
||||
(choose-palette id)
|
||||
(assoc-in [:project :status] (str "imported " (:name palette)))))))
|
||||
|
||||
(rf/reg-event-fx
|
||||
|
|
@ -341,7 +347,8 @@
|
|||
(array-seq (.-symbols listed)))
|
||||
(mapv (fn [^js r]
|
||||
{:project (.-project r) :project-name (.-project_name r)
|
||||
:cid (.-cid r) :palette (.-palette r) :name (.-name r)})
|
||||
:cid (.-cid r) :palette (.-palette r) :name (.-name r)
|
||||
:hexes (vec (or (.-hexes r) #js []))})
|
||||
(array-seq (.-palettes listed)))])))
|
||||
(.catch (fn [error]
|
||||
(rf/dispatch [::failed (or (ex-message error) (str error))]))))))
|
||||
|
|
@ -727,14 +734,41 @@
|
|||
p {:id id :name "Untitled palette"
|
||||
:slots (mapv #(select-keys % [:name :hex]) (:slots pal/default-palette))}]
|
||||
(-> (edit/edit db #(assoc-in % [:palettes id] p))
|
||||
(assoc-in [:ui :palette] id)))))
|
||||
(choose-palette id)))))
|
||||
|
||||
(rf/reg-event-db
|
||||
::add-palette
|
||||
;; One of `palette/presets` into a project that does not have it yet.
|
||||
(fn [db [_ p]]
|
||||
(-> (edit/edit db #(assoc-in % [:palettes (:id p)] p))
|
||||
(assoc-in [:ui :palette] (:id p)))))
|
||||
(choose-palette (:id p)))))
|
||||
|
||||
(rf/reg-event-db
|
||||
::use-palette
|
||||
;; Symbol `sid` draws in palette `p`, adding it to the project first when it
|
||||
;; is from the shelf or another project: one edit, so one undo. The grid goes
|
||||
;; back to following the tab, which now draws in it.
|
||||
(fn [db [_ sid p]]
|
||||
(-> (edit/edit db #(-> %
|
||||
(update-in [:palettes (:id p)] (fn [had] (or had p)))
|
||||
(assoc-in [:symbols sid :palette] (:id p))))
|
||||
(update-in [:ui :palette] dissoc (get-in db [:ui :open])))))
|
||||
|
||||
(rf/reg-event-db
|
||||
::empty-unused-slots
|
||||
;; Every slot of palette `id` no shape in the project names goes back to
|
||||
;; empty, in place: slot numbers are shared by every palette and every drawing,
|
||||
;; so nothing moves. One edit, so one undo.
|
||||
(fn [db [_ id]]
|
||||
(let [clip (:clip (store/entry (:clip/current db)))
|
||||
p (get (pal/palettes clip) id)
|
||||
gone (pal/emptyable p (pal/slots-used (vals (:symbols clip))))]
|
||||
(if (empty? gone)
|
||||
(assoc-in db [:project :status] "no unused colours to empty")
|
||||
(-> (edit/edit db #(assoc-in % [:palettes id] (pal/empty-slots p gone)))
|
||||
(assoc-in [:project :status]
|
||||
(str "emptied " (count gone) " unused colour" (when (< 1 (count gone)) "s")
|
||||
" in " (:name p))))))))
|
||||
|
||||
(rf/reg-event-db
|
||||
::duplicate-palette
|
||||
|
|
@ -752,7 +786,7 @@
|
|||
(-> (edit/edit db #(assoc-in % [:palettes new-id]
|
||||
(assoc p :id new-id
|
||||
:name (str (:name p) " copy"))))
|
||||
(assoc-in [:ui :palette] new-id)))))))
|
||||
(choose-palette new-id)))))))
|
||||
|
||||
(rf/reg-event-db
|
||||
::palette-name
|
||||
|
|
@ -881,6 +915,16 @@
|
|||
(fn [n] (if reads (assoc n :reads reads) (dissoc n :reads)))))))
|
||||
|
||||
|
||||
;; How far node `id` reads ahead of its parent — a mouth's lead — in its own
|
||||
;; frames. Zero is no offset at all rather than an offset of zero.
|
||||
(rf/reg-event-db
|
||||
::set-lead
|
||||
(fn [db [_ sid id frames]]
|
||||
(edit/edit db #(update-in % [:symbols sid :nodes id]
|
||||
(fn [n] (if (zero? frames)
|
||||
(update n :time dissoc :offset)
|
||||
(assoc-in n [:time :offset] frames)))))))
|
||||
|
||||
(rf/reg-event-db
|
||||
::set-segment-interp
|
||||
(fn [db [_ sid id path left interp]]
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@
|
|||
(let [ops (resolve-frame i)
|
||||
active (clip/active-palette resolve-frame)]
|
||||
(-> ras
|
||||
(raster/clear! (pal/background-index palette active))
|
||||
(raster/clear! pal/bg-slot)
|
||||
(raster/draw-ops! ops))
|
||||
(-> (js/Promise.resolve
|
||||
(frame! exporter i
|
||||
|
|
|
|||
|
|
@ -468,8 +468,16 @@
|
|||
[:xform :pos] (ch/framed [(- (/ w 2) (* k (:x c)))
|
||||
(- (* 0.25 h) (* k (:y c)))])}))))
|
||||
|
||||
;; MOUTH LEAD, in seconds. Roto drawn a frame or two ahead of the sound reads as
|
||||
;; in sync, and roto drawn exactly on it reads late: an animator's standard
|
||||
;; practice, and a 12fps hold already shows each pose up to a frame after it
|
||||
;; happened. 1.5 frames at 12fps. It is stored as the mouth's `:time :offset` in
|
||||
;; the face's own (camera) frames, so the head and the footage under it stay
|
||||
;; where they are and only the mouth anticipates. See docs/animation-model.md.
|
||||
(def mouth-lead 0.125)
|
||||
|
||||
(defn- mouth-part [subject absent? obs
|
||||
{:keys [analysis verts anchor-avg contour-avg aperture-cut] :as params}
|
||||
{:keys [analysis verts anchor-avg contour-avg aperture-cut fps] :as params}
|
||||
{:keys [outer inner] :as inputs}]
|
||||
(let [own (partial feature/owned subject)
|
||||
mouth (own :mouth)
|
||||
|
|
@ -484,6 +492,7 @@
|
|||
:verts verts}})]
|
||||
{:nodes {:mouth
|
||||
{:id :mouth :name "mouth" :kind :poly :parent :head :z "a1"
|
||||
:time {:offset (js/Math.round (* mouth-lead (or fps 0)))}
|
||||
:channels {[:geom :pts] (dense rings 0 (prov :roto/lips-outer))
|
||||
[:style :color] (ch/framed 2)}}
|
||||
:mouth-in
|
||||
|
|
|
|||
|
|
@ -130,28 +130,21 @@
|
|||
(fn [clip _] (when clip (pal/compile clip))))
|
||||
|
||||
(rf/reg-sub
|
||||
::ramp
|
||||
:<- [::palette]
|
||||
(fn [compiled _] (:ramp compiled)))
|
||||
::frame-palette
|
||||
;; The palette the open tab's stage is in at the frame last painted: an id,
|
||||
;; or `{:from :to :t}` mid-blend. Each tab keeps its own.
|
||||
(fn [db _] (get-in db [:ui :frame-palette (get-in db [:ui :open])])))
|
||||
|
||||
(rf/reg-sub
|
||||
::palettes-shown
|
||||
:<- [::clip]
|
||||
:<- [::open]
|
||||
:<- [::store]
|
||||
:<- [::open-frame]
|
||||
:<- [::palette]
|
||||
;; The palettes the stage is drawing in at the playhead: the open symbol's own,
|
||||
;; BOTH ends while its palette lane blends from one to the next, and any an
|
||||
;; instance in it is set to. The palette strip asks it whether the palette it
|
||||
;; is editing is one of these.
|
||||
(fn [[document sid store frame compiled] _]
|
||||
(when-let [sym (and document (clip/symbol document sid))]
|
||||
(let [at #(clip/palette-at document store (:default compiled) % (or frame 0) nil)
|
||||
ends #(if (map? %) [(:from %) (:to %)] [%])]
|
||||
(into (set (ends (at sym)))
|
||||
(comp (filter :palette) (mapcat (comp ends at)))
|
||||
(vals (:nodes sym)))))))
|
||||
::palette-solo?
|
||||
;; Show only what is drawn in the chosen colour, and let only it be clicked.
|
||||
(fn [db _] (get-in db [:ui :palette-solo?])))
|
||||
|
||||
(rf/reg-sub
|
||||
::palette-preview
|
||||
;; A palette under the pointer in the chooser: `{:bank id :hexes […]}`, the
|
||||
;; bank the stage would draw it into. Viewing only; nothing is edited.
|
||||
(fn [db _] (get-in db [:ui :palette-preview])))
|
||||
|
||||
(rf/reg-sub
|
||||
::store
|
||||
|
|
|
|||
|
|
@ -16,29 +16,62 @@
|
|||
set before you draw, so it is a section of the inspector. See `ui/params`."
|
||||
(:require [arthur.domain.channel :as channel]
|
||||
[arthur.domain.clip :as clip]
|
||||
[arthur.domain.raster :as raster]
|
||||
[arthur.footage.store :as store]
|
||||
[arthur.domain.node :as node]
|
||||
[arthur.domain.palette :as pal]
|
||||
[arthur.domain.symbol :as symbol]
|
||||
[arthur.subs.playback :as playback]
|
||||
[arthur.events.project :as project]
|
||||
[arthur.events.ui :as ui]
|
||||
[arthur.subs.render :as render]
|
||||
[arthur.subs.ui :as sub]
|
||||
[arthur.ui.canvas :as canvas]
|
||||
[arthur.ui.menu :as menu]
|
||||
[clojure.string :as str]
|
||||
[re-frame.core :as rf]
|
||||
[reagent.core :as r]))
|
||||
|
||||
(rf/reg-sub ::chosen (fn [db _] (get-in db [:ui :palette])))
|
||||
;; WHICH PALETTE THE GRID SHOWS
|
||||
;;
|
||||
;; The one the open tab's stage is in at the playhead — there is only ever one
|
||||
;; — read from where the player decided it, so the grid can never disagree with
|
||||
;; the picture. Another can be picked to look at or retone, and each tab keeps
|
||||
;; its own pick until the active one is picked again.
|
||||
|
||||
(rf/reg-event-db ::select (fn [db [_ id]] (assoc-in db [:ui :palette] id)))
|
||||
(rf/reg-sub ::chosen (fn [db _] (get-in db [:ui :palette (get-in db [:ui :open])])))
|
||||
|
||||
(rf/reg-sub
|
||||
::followed
|
||||
:<- [::render/frame-palette]
|
||||
:<- [::render/palette]
|
||||
;; Mid-tween, the palette it starts from, held still for the whole tween:
|
||||
;; the only things to do with a tween are change its ends, so the grid shows
|
||||
;; the start's own colours rather than the mix.
|
||||
(fn [[active compiled] _]
|
||||
(let [id (if (map? active) (:from active) active)]
|
||||
(if (contains? (:palettes compiled) id) id (:default compiled)))))
|
||||
|
||||
(rf/reg-event-db ::solo (fn [db _] (update-in db [:ui :palette-solo?] not)))
|
||||
|
||||
(rf/reg-event-db
|
||||
::select
|
||||
(fn [db [_ id followed]]
|
||||
(let [open (get-in db [:ui :open])]
|
||||
(if (= id followed)
|
||||
(update-in db [:ui :palette] dissoc open)
|
||||
(project/choose-palette db id)))))
|
||||
|
||||
(rf/reg-event-db ::preview (fn [db [_ p]] (assoc-in db [:ui :palette-preview] p)))
|
||||
|
||||
(defn- shown
|
||||
"The palette asset the grid shows: the one chosen, or the project's default."
|
||||
"The palette asset the grid shows, and the one the tab draws in."
|
||||
[]
|
||||
(let [clip @(rf/subscribe [::render/clip])
|
||||
chosen @(rf/subscribe [::chosen])
|
||||
pid (if (contains? (:palettes clip) chosen) chosen (pal/default-palette-id clip))]
|
||||
[clip pid (get (pal/palettes clip) pid)]))
|
||||
followed @(rf/subscribe [::followed])
|
||||
pid (if (contains? (:palettes clip) chosen) chosen followed)]
|
||||
[clip pid (get (pal/palettes clip) pid) followed]))
|
||||
|
||||
(defn- pick!
|
||||
"Make `tone` the colour new shapes get, and recolour what is selected."
|
||||
|
|
@ -123,14 +156,14 @@
|
|||
:title (if (= i from) (str i " — as it is") (str "slot " i))
|
||||
:on-click #(do (map-slot! rm from i) (reset! open nil))}]))])]))))
|
||||
|
||||
(defn- swatch [pid i {:keys [name hex]} tone placements rm hex-of]
|
||||
(defn- swatch [pid i {:keys [name hex]} tone placements rm hex-of used?]
|
||||
(let [picker-id (str "palette-picker-" pid "-" i)
|
||||
to (get (:map rm) i)]
|
||||
[:div.slot {:key i}
|
||||
[:button {:class (str "cell" (when (= i tone) " on"))
|
||||
[:button {:class (str "cell" (when (= i tone) " on") (when-not used? " unused"))
|
||||
:style {:background hex}
|
||||
:title (str "slot " i (when name (str " · " (clojure.core/name name)))
|
||||
" · " hex
|
||||
" · " hex (when-not used? " · nothing in the project draws with it")
|
||||
(when to (str " · lit as " to " under the selected remap"))
|
||||
" — double-click to edit"
|
||||
(when rm ", drag onto another to remap it under the selected remap"))
|
||||
|
|
@ -153,11 +186,18 @@
|
|||
(defn grid
|
||||
"The colour chip and the slots, for the tool strip."
|
||||
[]
|
||||
(let [[_ pid palette] (shown)
|
||||
(let [[clip pid palette followed] (shown)
|
||||
tone @(rf/subscribe [::sub/tone])
|
||||
solo? @(rf/subscribe [::render/palette-solo?])
|
||||
placements @(rf/subscribe [::sub/selected-placements])
|
||||
used (conj (pal/slots-used (vals (:symbols clip))) pal/bg-slot)
|
||||
hex (when (number? tone) (:hex (get (:slots palette) tone)))]
|
||||
[:div.palette
|
||||
[:div.palette-grid
|
||||
(when (not= pid followed)
|
||||
[:button.back {:title (str "back to " (:name (get (pal/palettes clip) followed))
|
||||
", the palette the stage is in")
|
||||
:on-click #(rf/dispatch [::select followed followed])}
|
||||
"↩ active"])
|
||||
[:div {:class (str "chip" (cond (= :clear tone) " clear" (symbol/remap? tone) " map"))
|
||||
:style (when hex {:background hex})
|
||||
:title (cond (= :clear tone) "clear: what is drawn knocks out what is under it in its symbol"
|
||||
|
|
@ -166,7 +206,8 @@
|
|||
[:span (cond (= :clear tone) "×" (symbol/remap? tone) "⇄" :else tone)]]
|
||||
[:div.cells
|
||||
(let [rm (remap) hex-of #(:hex (get (:slots palette) %))]
|
||||
(doall (map-indexed #(swatch pid %1 %2 tone placements rm hex-of) (:slots palette))))
|
||||
(doall (map-indexed #(swatch pid %1 %2 tone placements rm hex-of (contains? used %1))
|
||||
(:slots palette))))
|
||||
[:div.slot
|
||||
[:button {:class (str "cell clear" (when (= :clear tone) " on"))
|
||||
:title "clear — draws a knockout: a hole in its symbol"
|
||||
|
|
@ -175,7 +216,22 @@
|
|||
[:button {:class (str "cell map" (when (symbol/remap? tone) " on"))
|
||||
:title "remap — draws light: what is under it is drawn in other slots of the palette. Set which in the inspector."
|
||||
:on-click #(pick! [:remap {}] placements)}
|
||||
"⇄"]]]]))
|
||||
"⇄"]]]
|
||||
[:div.grid-tools
|
||||
[:button {:class (when solo? "on")
|
||||
:disabled (not (number? tone))
|
||||
:title (if solo?
|
||||
"showing only what is drawn in this colour — click one to select it; click again to show everything"
|
||||
"show only what is drawn in the chosen colour, to find and recolour it")
|
||||
:aria-pressed (boolean solo?)
|
||||
:on-click #(rf/dispatch [::solo])}
|
||||
"◎"]
|
||||
[:button {:title (str "empty the colours of " (:name palette)
|
||||
" no shape in the project draws with — they stay as free slots."
|
||||
" The background and the named face tones are kept.")
|
||||
:aria-label "empty unused colours"
|
||||
:on-click #(rf/dispatch [::project/empty-unused-slots pid])}
|
||||
"⌫"]]]))
|
||||
|
||||
(defn strip
|
||||
"Every slot of a palette, side by side: what it looks like at a glance."
|
||||
|
|
@ -201,71 +257,168 @@
|
|||
(.blur (.-target e)))
|
||||
nil))}])
|
||||
|
||||
(defn- chooser
|
||||
"Every palette in the project as a row — its strip and its name — so what you
|
||||
would switch to is visible before you switch. The open one carries the edit
|
||||
button that renames it; the ones the stage is drawing in at the playhead carry
|
||||
a dot."
|
||||
[clip pid]
|
||||
(r/with-let [renaming? (r/atom false)]
|
||||
(let [on-stage @(rf/subscribe [::render/palettes-shown])]
|
||||
[:div.palette-list {:role "listbox" :aria-label "palettes"}
|
||||
(doall
|
||||
(for [[id p] (sort-by (comp str :name val) (pal/palettes clip))
|
||||
:let [open? (= id pid)]]
|
||||
^{:key (str id)}
|
||||
[:div.palette-row {:class (when open? "on")}
|
||||
(if (and open? @renaming?)
|
||||
[:div.choose [strip p] [rename id p #(reset! renaming? false)]]
|
||||
[:button.choose {:role "option" :aria-selected open?
|
||||
:title (if open? (str "editing " (:name p)) (str "edit " (:name p)))
|
||||
(defn- authored?
|
||||
"Not exactly one of the shelf's: a palette someone made or retoned."
|
||||
[hexes]
|
||||
(not-any? #(= hexes (pal/hexes-of %)) pal/presets))
|
||||
|
||||
(defonce ^:private thumbs (atom {:key nil :raster nil :urls {}}))
|
||||
|
||||
(defn- frame-raster
|
||||
"The open symbol's frame at the playhead, as indices: drawn once, then shown
|
||||
through each palette's colours, so a list of thumbnails costs one render and a
|
||||
colour lookup per row."
|
||||
[clip store compiled open frame]
|
||||
(let [k [clip open frame]]
|
||||
(when-not (= k (:key @thumbs))
|
||||
(reset! thumbs
|
||||
{:key k :urls {}
|
||||
:raster (try
|
||||
(let [resolve (clip/resolver clip open store compiled {})
|
||||
[w h] (clip/stage clip open)
|
||||
ops (resolve (or frame 0))]
|
||||
(-> (raster/make w h)
|
||||
(raster/clear! pal/bg-slot)
|
||||
(raster/draw-ops! ops)))
|
||||
(catch :default _ nil))}))
|
||||
(:raster @thumbs)))
|
||||
|
||||
(defn- thumb
|
||||
"The playhead's frame in `hexes`."
|
||||
[hexes]
|
||||
(let [k hexes]
|
||||
(or (get-in @thumbs [:urls k])
|
||||
(when-let [r (:raster @thumbs)]
|
||||
(let [url (canvas/->png r (pal/ramp-of hexes))]
|
||||
(swap! thumbs assoc-in [:urls k] url)
|
||||
url)))))
|
||||
|
||||
(defn- hit? [needle & texts]
|
||||
(or (str/blank? needle)
|
||||
(some #(str/includes? (str/lower-case (str %)) needle) texts)))
|
||||
|
||||
(def ^:private via-words {:symbol "set on symbol" :lane "palette lane" :instance "instance"})
|
||||
|
||||
(defn- candidate-row
|
||||
"One palette to switch to: a thumbnail of the playhead's frame in it, its strip,
|
||||
its name and where it is from. Hovering shows it on the stage; clicking opens
|
||||
it in the grid; `use` makes the open symbol draw in it."
|
||||
[{:keys [p note on? thumb-url sid followed]}]
|
||||
(let [hexes (pal/hexes-of p)]
|
||||
[:div.palette-row {:class (when on? "on")
|
||||
:on-mouse-enter #(rf/dispatch [::preview {:hexes hexes}])
|
||||
:on-mouse-leave #(rf/dispatch [::preview nil])}
|
||||
[:button.choose {:role "option" :aria-selected (boolean on?)
|
||||
:title (str "show " (:name p) " in the palette grid")
|
||||
:on-click (fn []
|
||||
(when-not open?
|
||||
(reset! renaming? false)
|
||||
(rf/dispatch [::ui/set-tone 0])
|
||||
(rf/dispatch [::select id])))}
|
||||
(rf/dispatch [::preview nil])
|
||||
(if (contains? (pal/palettes @(rf/subscribe [::render/clip])) (:id p))
|
||||
(rf/dispatch [::select (:id p) followed])
|
||||
(rf/dispatch [::project/add-palette p])))}
|
||||
(when thumb-url [:img.thumb {:src thumb-url :alt ""}])
|
||||
[:span.text
|
||||
[strip p]
|
||||
[:span.name (:name p)]
|
||||
(when (contains? on-stage id)
|
||||
[:span.on-stage {:title "on the stage at the playhead"}])])
|
||||
(when open?
|
||||
[:button.rename {:title (str "rename " (:name p)) :aria-label "rename palette"
|
||||
:on-click #(swap! renaming? not)}
|
||||
"✎"])]))])))
|
||||
(when note [:span.note note])]]
|
||||
[:button.use {:title (str "draw " (clip/symbol-name @(rf/subscribe [::render/clip]) sid)
|
||||
" in " (:name p))
|
||||
:on-click (fn []
|
||||
(rf/dispatch [::preview nil])
|
||||
(rf/dispatch [::project/use-palette sid p]))}
|
||||
"use"]]))
|
||||
|
||||
(defn- elsewhere
|
||||
"An info badge on the palette button when the palette being edited is not one
|
||||
the stage draws in at the playhead — not an error: editing another palette is
|
||||
how one is made ready for a palette lane. Hovering says where to change it.
|
||||
The card is placed in the viewport, as `ui/menu` places its panels, because
|
||||
the tool strip scrolls and clips its overflow."
|
||||
[pid palette]
|
||||
(r/with-let [at (r/atom nil)]
|
||||
(let [on-stage @(rf/subscribe [::render/palettes-shown])
|
||||
clip @(rf/subscribe [::render/clip])
|
||||
sid @(rf/subscribe [::render/open])]
|
||||
(when (and (seq on-stage) (not (contains? on-stage pid)))
|
||||
[:span.palette-info
|
||||
{:aria-label "palette not on the stage here"
|
||||
:on-mouse-enter (fn [^js e]
|
||||
(let [r (.getBoundingClientRect (.-currentTarget e))]
|
||||
(reset! at [(+ (.-right r) 8) (- (.-top r) 6)])))
|
||||
:on-mouse-leave #(reset! at nil)}
|
||||
"i"
|
||||
(when-let [[x y] @at]
|
||||
[:span.info-card {:role "tooltip" :style {:left (str x "px") :top (str y "px")}}
|
||||
[:strong (str (:name palette) " isn't on the stage here")]
|
||||
(str (or (clip/symbol-name clip sid) "This symbol")
|
||||
" draws in " (str/join " and " (map #(:name (get (pal/palettes clip) %)) on-stage))
|
||||
" at this frame. To draw in " (:name palette)
|
||||
", set the authoring palette in the symbol inspector, or blend to it with a palette lane.")])]))))
|
||||
(defn- shelf
|
||||
"The classics, small: a strip each and a name under it, folded away until
|
||||
wanted. Hovering previews; a click brings one into the project."
|
||||
[ps followed searching? sid]
|
||||
[:details.palette-shelf {:open searching?}
|
||||
[:summary (str "classics · " (count ps))]
|
||||
[:div.shelf
|
||||
(doall
|
||||
(for [p ps]
|
||||
^{:key (str (:id p))}
|
||||
[:button.tile {:title (str (:name p) " — click to open it, double-click to use it")
|
||||
:on-mouse-enter #(rf/dispatch [::preview {:hexes (pal/hexes-of p)}])
|
||||
:on-mouse-leave #(rf/dispatch [::preview nil])
|
||||
:on-click (fn []
|
||||
(rf/dispatch [::preview nil])
|
||||
(if (contains? (pal/palettes @(rf/subscribe [::render/clip])) (:id p))
|
||||
(rf/dispatch [::select (:id p) followed])
|
||||
(rf/dispatch [::project/add-palette p])))
|
||||
:on-double-click #(rf/dispatch [::project/use-palette sid p])}
|
||||
[strip p] [:span.name (:name p)]]))]])
|
||||
|
||||
(defn- chooser
|
||||
"Every palette worth switching to, most relevant first: those the open
|
||||
symbol's tree draws in, saying where; the rest of this project's; those made
|
||||
in other projects, with the project's name; then the classics, folded. One
|
||||
search reaches palette names and project names."
|
||||
[clip pid followed]
|
||||
(r/with-let [renaming? (r/atom false) query (r/atom "")]
|
||||
(let [sid @(rf/subscribe [::render/open])
|
||||
compiled @(rf/subscribe [::render/palette])
|
||||
frame @(rf/subscribe [::render/open-frame])
|
||||
clip-id @(rf/subscribe [::render/clip-id])
|
||||
listed (:palettes @(rf/subscribe [::project/assets]))
|
||||
{project-id :id} @(rf/subscribe [::playback/project])
|
||||
needle (str/lower-case (str/trim @query))
|
||||
searching? (not (str/blank? needle))
|
||||
_ (frame-raster clip (:store (store/entry clip-id)) compiled sid frame)
|
||||
own (pal/palettes clip)
|
||||
uses (group-by :palette
|
||||
(cons {:palette (pal/default-palette-id clip) :project? true}
|
||||
(clip/palette-uses clip sid)))
|
||||
note-of (fn [id]
|
||||
(str/join ", " (for [{:keys [sid via project?]} (get uses id)]
|
||||
(if project? "project"
|
||||
(str (clip/symbol-name clip sid) " · " (via-words via))))))
|
||||
row (fn [p note]
|
||||
{:p p :note note :on? (= (:id p) pid) :sid sid :followed followed
|
||||
:thumb-url (thumb (pal/hexes-of p))})
|
||||
here (for [[id p] own :when (contains? uses id)] (row p (note-of id)))
|
||||
project (for [[id p] own
|
||||
:when (and (not (contains? uses id)) (authored? (pal/hexes-of p)))]
|
||||
(row p nil))
|
||||
have (set (map pal/hexes-of (vals own)))
|
||||
elsewhere (->> listed
|
||||
(remove #(= project-id (:project %)))
|
||||
(filter #(and (seq (:hexes %)) (authored? (:hexes %))
|
||||
(not (contains? have (:hexes %)))))
|
||||
(group-by (juxt :name :hexes))
|
||||
(map (fn [[[label hexes] rows]]
|
||||
(let [projects (str/join ", " (distinct (map :project-name rows)))]
|
||||
(assoc (row (pal/from-hexes (random-uuid) label hexes) projects)
|
||||
:key [label hexes] :search projects))))
|
||||
(sort-by (comp str/lower-case :name :p)))
|
||||
keep (fn [rows] (filter #(hit? needle (:name (:p %)) (:note %)) rows))
|
||||
section (fn [title rows]
|
||||
(when (seq rows)
|
||||
[:<>
|
||||
[:div.palette-head title]
|
||||
(doall (for [r rows] ^{:key (str (or (:key r) (:id (:p r))))} [candidate-row r]))]))]
|
||||
[:div.palette-chooser
|
||||
[:input.palette-search {:type "search" :placeholder "search palettes and projects"
|
||||
:aria-label "search palettes"
|
||||
:value @query :on-change #(reset! query (.. % -target -value))}]
|
||||
[:div.palette-list {:role "listbox" :aria-label "palettes"}
|
||||
[section (str "in " (clip/symbol-name clip sid)) (keep here)]
|
||||
[section "this project" (keep project)]
|
||||
[section "your palettes" (keep elsewhere)]]
|
||||
(when-let [open-p (and (not searching?) (get own pid))]
|
||||
[:div.palette-editing
|
||||
(if @renaming?
|
||||
[rename pid open-p #(reset! renaming? false)]
|
||||
[:<> [:span.dim "editing"] [:span.name (:name open-p)]
|
||||
[:button.rename {:title (str "rename " (:name open-p)) :aria-label "rename palette"
|
||||
:on-click #(swap! renaming? not)} "✎"]])])
|
||||
[shelf (filter #(hit? needle (:name %)) pal/presets) followed searching? sid]])))
|
||||
|
||||
(defn assets
|
||||
"The palettes behind a button at the foot of the strip: switch, rename, add.
|
||||
The name is NOT printed in the strip: 44px holds no palette's name, and a name
|
||||
broken over three lines is worse than one shown when asked for."
|
||||
[]
|
||||
(let [[clip pid palette] (shown)]
|
||||
(let [[clip pid palette followed] (shown)]
|
||||
[:div.palette-assets-wrap
|
||||
[menu/popover {:class "palette-assets" :title (str "palette: " (:name palette))
|
||||
:label [:svg {:view-box "0 0 18 18" :width 18 :height 18}
|
||||
|
|
@ -275,18 +428,8 @@
|
|||
[:circle {:cx 12.5 :cy 6.5 :r 1.3}]]}
|
||||
(fn [_]
|
||||
[:div.palette-popout
|
||||
[chooser clip pid]
|
||||
[chooser clip pid followed]
|
||||
[:div.row
|
||||
[:button {:title "a new 16-slot palette" :on-click #(rf/dispatch [::project/new-palette])} "new"]
|
||||
[:button {:title (str "a copy of " (:name palette) " you can retone")
|
||||
:on-click #(rf/dispatch [::project/duplicate-palette pid])} "duplicate"]]
|
||||
(when-let [missing (seq (remove #(contains? (pal/palettes clip) (:id %)) pal/presets))]
|
||||
[:div.palette-list {:aria-label "presets"}
|
||||
(doall
|
||||
(for [p missing]
|
||||
^{:key (str (:id p))}
|
||||
[:div.palette-row
|
||||
[:button.choose {:title (str "add " (:name p) " to this project")
|
||||
:on-click #(rf/dispatch [::project/add-palette p])}
|
||||
[strip p] [:span.name (str "+ " (:name p))]]]))])])]
|
||||
[elsewhere pid palette]]))
|
||||
:on-click #(rf/dispatch [::project/duplicate-palette pid])} "duplicate"]]])]]))
|
||||
|
|
|
|||
|
|
@ -84,13 +84,17 @@
|
|||
[label & controls]
|
||||
(into [:div.prop [:span.prop-name label]] controls))
|
||||
|
||||
(defn- palette-select [value on-change & [disabled?]]
|
||||
(defn- palette-select
|
||||
"A choice of the project's palettes. `inherit` names the empty choice — what
|
||||
an unset palette falls back to — and false leaves it out."
|
||||
[value on-change & [disabled? inherit]]
|
||||
(let [clip @(rf/subscribe [::render/clip])]
|
||||
[:select {:value (str (or value "")) :disabled disabled?
|
||||
:on-change (fn [e]
|
||||
(let [v (.. e -target -value)]
|
||||
(on-change (first (filter #(= v (str %)) (keys (pal/palettes clip)))))))}
|
||||
[:option {:value ""} "inherit"]
|
||||
(when-not (false? inherit)
|
||||
[:option {:value ""} (or inherit "inherit")])
|
||||
(for [[id p] (sort-by (comp str :name val) (pal/palettes clip))]
|
||||
^{:key (str id)} [:option {:value (str id)} (:name p)])]))
|
||||
|
||||
|
|
@ -271,8 +275,8 @@
|
|||
clip @(rf/subscribe [::render/clip])
|
||||
frame (:frame @(rf/subscribe [::sub/selected-placement]))
|
||||
own @(rf/subscribe [::sub/own-time node-path])
|
||||
palette (get (pal/palettes clip)
|
||||
(or (get-in clip [:symbols sid :palette]) (pal/default-palette-id clip)))]
|
||||
;; What the shape is drawn in, which is what the grid follows.
|
||||
palette (get (pal/palettes clip) @(rf/subscribe [:arthur.ui.palette/followed]))]
|
||||
[:div.chans
|
||||
(doall
|
||||
(for [[path ch] (sort-by (fn [[path]] [(get order path 99) (str path)]) (node/channels n))]
|
||||
|
|
@ -340,7 +344,12 @@
|
|||
:on-click #(do (put! :width nil) (put! :height nil))}
|
||||
"↺"]))
|
||||
(prop "palette"
|
||||
[palette-select (:palette sym) #(rf/dispatch [::project/symbol-palette sid %]) busy?])]))
|
||||
[palette-select (:palette sym) #(rf/dispatch [::project/symbol-palette sid %]) busy?
|
||||
;; Unset, a symbol draws in what it is placed in, and on its own in
|
||||
;; the project's palette.
|
||||
(if (pos? (clip-domain/uses clip sid))
|
||||
"from where it's placed"
|
||||
(str "project's · " (:name (get (pal/palettes clip) (pal/default-palette-id clip)))))])]))
|
||||
|
||||
(defn- project-fields []
|
||||
(let [clip @(rf/subscribe [::render/clip])
|
||||
|
|
@ -355,7 +364,10 @@
|
|||
[:span.dim "×"]
|
||||
[count-input (:height clip) #(rf/dispatch [::project/project-setting :height %])
|
||||
{:disabled busy? :label "height"}])
|
||||
(prop "rate" [settings/rate busy?])]))
|
||||
(prop "rate" [settings/rate busy?])
|
||||
(prop "palette"
|
||||
[palette-select (pal/default-palette-id clip)
|
||||
#(when % (rf/dispatch [::project/default-palette %])) busy? false])]))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; a node
|
||||
|
|
@ -691,6 +703,26 @@
|
|||
(when (seq faces)
|
||||
(filterv #(contains? faces (subject-of-owner clip %)) (owners clip)))))
|
||||
|
||||
(defn- lead-row
|
||||
"How far feature `fid`'s drawing reads ahead of the sound, as its first node's
|
||||
`:time :offset`. Stored in the face's own camera frames and typed in the
|
||||
document's, because the document's grid is what a lead is felt against."
|
||||
[clip fid]
|
||||
(let [{face :symbol [id] :nodes} (get-in clip [:features fid])
|
||||
face-fps (get-in clip [:analyses (get-in clip [:subjects face :analysis]) :fps])
|
||||
fps (:fps clip)
|
||||
offset (get-in clip [:symbols face :nodes id :time :offset] 0)]
|
||||
(when (and face-fps fps)
|
||||
[:div.prop {:style {:margin-top "6px"}
|
||||
:title "roto drawn a frame or two ahead of the sound reads as in sync"}
|
||||
[:span.prop-name "lead"]
|
||||
[number-input {:step 0.5 :aria-label "lead in frames"
|
||||
:value (/ (js/Math.round (* 10 offset (/ fps face-fps))) 10)
|
||||
:parse js/parseFloat
|
||||
:on-number #(rf/dispatch [::project/set-lead face id
|
||||
(js/Math.round (* % (/ face-fps fps)))])}]
|
||||
[:span.dim (str "f · " (js/Math.round (/ (* 1000 offset) face-fps)) "ms")]])))
|
||||
|
||||
(defn- tracking-section [all]
|
||||
(let [clip @(rf/subscribe [::render/clip])
|
||||
selection @(rf/subscribe [::sub/selection])
|
||||
|
|
@ -723,6 +755,7 @@
|
|||
(for [[i [kind object-id]] (map-indexed vector all)]
|
||||
^{:key i}
|
||||
[:option {:value i} (str (name kind) " · " (subs (str object-id) 1))]))]
|
||||
(when (= :mouth area) [lead-row clip id])
|
||||
(when area
|
||||
[:div {:style {:margin-top "6px"}}
|
||||
(doall
|
||||
|
|
@ -896,9 +929,9 @@
|
|||
[layer-section "tracing" (first node) (second node) path])
|
||||
(when (get-in clip [:symbols face :nodes :plate])
|
||||
[face-section face path])
|
||||
(when a-face? ^{:key (str "repair/" face)} [repair-section face path])
|
||||
(when a-face? ^{:key (str "perf/" face)} [performance-section face])
|
||||
(when (and (seq tracking-owners) (not palette-placement?) (not palette-symbol?))
|
||||
[tracking-section tracking-owners])
|
||||
(when a-face? ^{:key (str "repair/" face)} [repair-section face path])
|
||||
(when a-face? ^{:key (str "perf/" face)} [performance-section face])
|
||||
(when (= [:symbol (clip-domain/opens-on clip)] inspected)
|
||||
[project-fields])]]))
|
||||
|
|
|
|||
|
|
@ -118,7 +118,8 @@
|
|||
(fn [_ _]
|
||||
{:resolver (rf/subscribe [::render/shown])
|
||||
:palette (rf/subscribe [::render/palette])
|
||||
:ramp (rf/subscribe [::render/ramp])
|
||||
:preview (rf/subscribe [::render/palette-preview])
|
||||
:solo? (rf/subscribe [::render/palette-solo?])
|
||||
:fps (rf/subscribe [::sub/fps])
|
||||
:frames (rf/subscribe [::render/frames])
|
||||
:width (rf/subscribe [::sub/width])
|
||||
|
|
@ -160,8 +161,8 @@
|
|||
;; in the editor's own state, so it changes what the canvases should
|
||||
;; show without touching the frame number OR the resolver.
|
||||
(when-not (and (identical? (:resolver before) (:resolver now))
|
||||
(= (select-keys before [:tracing :pen :mat :onion :selection :playing?])
|
||||
(select-keys now [:tracing :pen :mat :onion :selection :playing?])))
|
||||
(= (select-keys before [:tracing :pen :mat :onion :selection :playing? :preview :solo?])
|
||||
(select-keys now [:tracing :pen :mat :onion :selection :playing? :preview :solo?])))
|
||||
(repaint!))))))
|
||||
|
||||
;; The brush or eraser stroke being painted: its mask, mutated in place as the
|
||||
|
|
@ -309,11 +310,6 @@
|
|||
(defn in-rect [rect depth]
|
||||
(pick/in-rect (:ops @state) rect depth))
|
||||
|
||||
(defn- index-of-slot [palette active slot]
|
||||
(if (and (:palettes palette) (:offsets palette))
|
||||
(pal/render-index palette active slot)
|
||||
slot))
|
||||
|
||||
(defn- traced
|
||||
"Stroke `s` as the rings letting go would make of it, `[outer & holes]` per
|
||||
piece: traced and simplified by the same function the saved shapes are, so
|
||||
|
|
@ -346,17 +342,17 @@
|
|||
(defn- inked
|
||||
"Op `op` drawn in tone `tone`: a slot's colour, or — for a remap — light on
|
||||
what is under it, through the same table the saved shape gets."
|
||||
[op tone palette active]
|
||||
[op tone]
|
||||
(if (symbol/remap? tone)
|
||||
(assoc op :lut (symbol/lut #(index-of-slot palette active %) tone) :color 0)
|
||||
(assoc op :color (index-of-slot palette active tone))))
|
||||
(assoc op :lut (symbol/lut pal/slot tone) :color 0)
|
||||
(assoc op :color (pal/slot tone))))
|
||||
|
||||
(defn- with-previews
|
||||
"What is being drawn and is not in the document yet, added to `ops` in the
|
||||
stacking context of the symbol it will land in: the pen's draft as far as the
|
||||
pointer, a brush stroke as the polygons it will be, and an eraser's cut as
|
||||
the shapes it will leave."
|
||||
[ops palette active]
|
||||
[ops]
|
||||
(let [{:keys [draft hover tone fit target]} (:pen @snapshot)
|
||||
target (or target [])
|
||||
pts (cond-> (vec draft) (and (seq draft) hover) (into hover))
|
||||
|
|
@ -364,13 +360,13 @@
|
|||
rings (when (:mask s) (traced s fit))]
|
||||
(cond-> ops
|
||||
(and (<= 6 (count pts)) (or (number? tone) (symbol/remap? tone)))
|
||||
(clip/atop target (inked (poly pts {}) tone palette active))
|
||||
(clip/atop target (inked (poly pts {}) tone))
|
||||
|
||||
paths
|
||||
(cut-ops paths rings)
|
||||
|
||||
(and rings (not paths) (nil? knock))
|
||||
(as-> ops (reduce #(clip/atop %1 target (inked (poly (outline/join %2) {}) slot palette active))
|
||||
(as-> ops (reduce #(clip/atop %1 target (inked (poly (outline/join %2) {}) slot))
|
||||
ops rings))
|
||||
|
||||
(and rings (not paths) knock)
|
||||
|
|
@ -383,7 +379,9 @@
|
|||
rasterised before the next frame is asked for."
|
||||
[f]
|
||||
(let [{:keys [canvas]} @state
|
||||
{:keys [resolver palette ramp width height tracing playing? mat]} @snapshot]
|
||||
{:keys [resolver palette width height tracing playing? mat preview solo?] :as snap} @snapshot
|
||||
tone (get-in snap [:pen :tone])
|
||||
solo (when (and solo? (number? tone)) tone)]
|
||||
(when (and canvas resolver width height)
|
||||
;; User Timing, so a profile in the DevTools performance panel has named
|
||||
;; spans in the Timings track instead of a wall of anonymous frames. Three
|
||||
|
|
@ -400,12 +398,21 @@
|
|||
traces (when (:on? tracing)
|
||||
(into [] (remove #(contains? (:hidden tracing) (:layer %))) traces))
|
||||
active (clip/active-palette resolver)
|
||||
bg (pal/background-index palette active)]
|
||||
(swap! state assoc :ops (into (vec picture) traces))
|
||||
bg pal/bg-slot]
|
||||
;; The palette grid shows the frame's palette from here, the one place
|
||||
;; it is decided, rather than working it out again.
|
||||
;; Keyed by the resolver too, as a new tab brings a new one.
|
||||
(when (not= [resolver active] (:active @state))
|
||||
(swap! state assoc :active [resolver active])
|
||||
(rf/dispatch [::pb/frame-palette active]))
|
||||
;; Soloed, only what is drawn in the chosen colour can be clicked.
|
||||
(swap! state assoc :ops (if solo
|
||||
(filterv #(or (#{:begin :end} (:kind %)) (= solo (:color %))) picture)
|
||||
(into (vec picture) traces)))
|
||||
;; What is drawn, cut to what is on screen: a frame with nothing off the
|
||||
;; stage costs what the stage does, and a drawing a dozen stages wide
|
||||
;; costs no more than the pane it is seen through.
|
||||
(let [ops (with-previews picture palette active)
|
||||
(let [ops (with-previews picture)
|
||||
[ax ay bx by :as all] (reach ops width height)
|
||||
[vx vy wx wy] rect
|
||||
x0 (max ax vx) y0 (max ay vy) x1 (min bx wx) y1 (min by wy)]
|
||||
|
|
@ -415,7 +422,14 @@
|
|||
(let [off? (or (neg? x0) (neg? y0) (< width x1) (< height y1))
|
||||
ras (raster-for (- x1 x0) (- y1 y0) [x0 y0] off?)]
|
||||
(-> ras (raster/clear! bg) (raster/draw-ops! ops))
|
||||
(canvas/blit! canvas ras (pal/effective-ramp palette active) [width height]))
|
||||
(canvas/blit! canvas ras
|
||||
;; THE frame's colours: the one palette it is in,
|
||||
;; or the one being previewed in its place.
|
||||
(cond-> (if preview
|
||||
(pal/ramp-of (:hexes preview))
|
||||
(pal/effective-ramp palette active))
|
||||
solo (pal/solo-ramp solo))
|
||||
[width height]))
|
||||
(canvas/hide! canvas)))
|
||||
(tracing/paint! traces (assoc tracing :rect rect :zoom zoom :stage [width height] :playing? playing?) repaint!))
|
||||
(js/performance.measure "arthur/resolve+draw" "arthur/paint:start" "arthur/blit:start")
|
||||
|
|
|
|||
|
|
@ -98,29 +98,29 @@
|
|||
most phone footage opens on. A symbol's frame 0 is authored: what is on it is
|
||||
there because somebody put it there, and the frame a person names a symbol by
|
||||
is the one it starts on."
|
||||
[document sid store palette ramp]
|
||||
[document sid store palette]
|
||||
(try
|
||||
(when (clip/symbol document sid)
|
||||
(let [resolve (clip/resolver document sid store palette {})
|
||||
[w h] (clip/stage document sid)]
|
||||
(let [ops (resolve 0)]
|
||||
(-> (raster/make w h)
|
||||
(raster/clear! (pal/background-index palette (clip/active-palette resolve)))
|
||||
(raster/clear! pal/bg-slot)
|
||||
(raster/draw-ops! ops)
|
||||
(canvas/->png ramp)))))
|
||||
(canvas/->png (pal/effective-ramp palette (clip/active-palette resolve)))))))
|
||||
(catch :default _ nil)))
|
||||
|
||||
(defn- symbol-thumb
|
||||
"`draw-symbol`, once per symbol per version of the document. Rasterising and
|
||||
PNG-encoding the stage is milliseconds, and the pool redraws on every selection
|
||||
click."
|
||||
[document sid store palette ramp]
|
||||
[document sid store palette]
|
||||
(when-not (identical? document (:clip @thumbs))
|
||||
(reset! thumbs {:clip document :urls {}}))
|
||||
(let [urls (:urls @thumbs)]
|
||||
(if (contains? urls sid)
|
||||
(get urls sid)
|
||||
(let [url (draw-symbol document sid store palette ramp)]
|
||||
(let [url (draw-symbol document sid store palette)]
|
||||
(swap! thumbs assoc-in [:urls sid] url)
|
||||
url))))
|
||||
|
||||
|
|
@ -256,7 +256,7 @@
|
|||
;; ---------------------------------------------------------------------------
|
||||
;; the rows of each kind
|
||||
|
||||
(defn- symbol-row [document sid {:keys [clip-id store palette ramp selection open main rename]}]
|
||||
(defn- symbol-row [document sid {:keys [clip-id store palette selection open main rename]}]
|
||||
(let [sym (clip/symbol document sid)
|
||||
label (clip/symbol-name document sid)
|
||||
nodes (count (:nodes sym))]
|
||||
|
|
@ -271,7 +271,7 @@
|
|||
" — double-click to open, drag to place"))
|
||||
:thumb (if (= :trace (:type sym))
|
||||
[tracing-thumb (:media sym)]
|
||||
[picture (symbol-thumb document sid store palette ramp)])
|
||||
[picture (symbol-thumb document sid store palette)])
|
||||
:sub2 (str (:frames sym) "f · " nodes (if (= 1 nodes) " node" " nodes"))
|
||||
:on? (= selection [:symbol sid])
|
||||
:open? (= sid open)
|
||||
|
|
@ -441,7 +441,7 @@
|
|||
|
||||
Still not `:main` being special. The document says which symbol that is by its
|
||||
structure; rename it, place it inside something else, and the pool follows."
|
||||
[{:keys [document query searching? media sounds images chosen rename main palette-choice selection] :as ctx}]
|
||||
[{:keys [document query searching? media sounds images chosen rename main selection] :as ctx}]
|
||||
(let [named? #(hit? query (clip/symbol-name document %))
|
||||
top (when (and main (named? main)) main)
|
||||
symbol-ids (sort-by str (keys (:symbols document)))
|
||||
|
|
@ -566,9 +566,7 @@
|
|||
clip-id @(rf/subscribe [::render/clip-id])
|
||||
store @(rf/subscribe [::render/store])
|
||||
palette @(rf/subscribe [::render/palette])
|
||||
ramp @(rf/subscribe [::render/ramp])
|
||||
selection @(rf/subscribe [::sub/selection])
|
||||
palette-choice @(rf/subscribe [:arthur.ui.palette/chosen])
|
||||
open @(rf/subscribe [::render/open])
|
||||
media @(rf/subscribe [::sub/project-footage])
|
||||
{:keys [symbols palettes]} @(rf/subscribe [::project/assets])
|
||||
|
|
@ -588,12 +586,11 @@
|
|||
needle (str/lower-case (str/trim @query))
|
||||
searching? (boolean (seq needle))
|
||||
ctx {:document document :clip-id clip-id :store store :palette palette
|
||||
:ramp ramp :selection selection :open open
|
||||
:selection selection :open open
|
||||
:media media :sounds own-sounds :images own-images :chosen chosen
|
||||
:available (vec available) :all-sounds (vec sounds)
|
||||
:all-images (vec images)
|
||||
:symbols symbols :palettes palettes :project-id project-id
|
||||
:palette-choice palette-choice
|
||||
:query needle :searching? searching?
|
||||
;; `clip/opens-on` and not `:main`: the longest symbol nothing
|
||||
;; else places is the timeline the work happens in, and it is the
|
||||
|
|
|
|||
|
|
@ -644,6 +644,9 @@
|
|||
(defn- label-cell [{:keys [path depth label kind node-kind lane? span select expandable? expanded? of via uses]}
|
||||
selection selections target-path over solo tracing renaming draft choose-row!]
|
||||
(let [node? (= :node kind)
|
||||
;; The palette row is the symbol's one palette lane: "palette" says all
|
||||
;; there is to say, and it has no name of its own to change.
|
||||
named-lane? (and lane? (not= :palette kind))
|
||||
selected? (contains? selections select)
|
||||
editing? (and lane? (= select @renaming))
|
||||
begin-rename! (fn [] (reset! draft label) (reset! renaming select))
|
||||
|
|
@ -751,9 +754,9 @@
|
|||
[:span.uses {:title (str "placed " uses " times · a rename reaches every one")}
|
||||
(str "(" uses ")")])
|
||||
(cond
|
||||
lane? [:span.kind "·lane"]
|
||||
named-lane? [:span.kind "·lane"]
|
||||
node? [:span.kind (if via (str "· in " via) (str "·" (name node-kind)))])
|
||||
(when lane?
|
||||
(when named-lane?
|
||||
[:button.tl-rename
|
||||
{:title "rename lane"
|
||||
:on-click (fn [^js e] (.stopPropagation e) (begin-rename!))}
|
||||
|
|
|
|||
|
|
@ -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")}
|
||||
[: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 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)))))
|
||||
|
||||
(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}
|
||||
{: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}}}}
|
||||
: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))))))
|
||||
:ink-palette {:id :ink-palette :type :palette :palette-ref :ink :frames 1 :nodes {}}}}))
|
||||
|
||||
(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;
|
||||
|
|
|
|||
|
|
@ -1446,7 +1446,7 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
|
|||
color: var(--dim);
|
||||
}
|
||||
.key-nav button:disabled { opacity: .3; }
|
||||
.key-nav .key { width: 16px; }
|
||||
.key-nav .key { width: 16px; font-size: 15px; line-height: 1; }
|
||||
.key-nav .key.keyed { color: var(--fg); }
|
||||
.key-nav .key.on { color: var(--sel); }
|
||||
.key-nav svg, .chan .gap svg, .prop .seg svg { width: 11px; height: 11px; }
|
||||
|
|
@ -1675,38 +1675,38 @@ button.tl-gap:hover { background: rgba(47, 111, 192, .28); }
|
|||
.tool svg .cut { fill: none; stroke: var(--chrome); stroke-width: 1.2; }
|
||||
.tool.on svg .cut { stroke: var(--sel-bg); }
|
||||
|
||||
.palette { display: grid; gap: 7px; justify-items: center; padding-top: 9px; border-top: 1px solid var(--hair); }
|
||||
.palette-grid { display: grid; gap: 7px; justify-items: center; padding-top: 9px; border-top: 1px solid var(--hair); }
|
||||
|
||||
/* The colour a new shape gets: Photoshop's foreground chip. */
|
||||
.palette .chip {
|
||||
.palette-grid .chip {
|
||||
width: 36px; height: 36px;
|
||||
display: grid; place-items: end start;
|
||||
border: 1px solid var(--fg);
|
||||
border-radius: 3px;
|
||||
box-shadow: inset 0 0 0 2px var(--pane);
|
||||
}
|
||||
.palette .chip span {
|
||||
.palette-grid .chip span {
|
||||
margin: 0 0 2px 3px; padding: 0 3px;
|
||||
border-radius: 2px;
|
||||
background: rgba(255, 255, 255, .85);
|
||||
color: var(--fg); font-size: 9px; line-height: 12px;
|
||||
}
|
||||
|
||||
.palette .cells { display: grid; grid-template-columns: repeat(2, 17px); gap: 2px; }
|
||||
.palette .slot { display: contents; }
|
||||
.palette .cell {
|
||||
.palette-grid .cells { display: grid; grid-template-columns: repeat(2, 17px); gap: 2px; }
|
||||
.palette-grid .slot { display: contents; }
|
||||
.palette-grid .cell {
|
||||
width: 17px; height: 17px;
|
||||
padding: 0;
|
||||
border: 1px solid rgba(0, 0, 0, .35);
|
||||
border-radius: 2px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.palette .cell:hover { border-color: var(--fg); transform: scale(1.12); }
|
||||
.palette .cell.on { border-color: var(--fg); box-shadow: 0 0 0 1px var(--pane), 0 0 0 2px var(--sel); position: relative; z-index: 1; }
|
||||
.palette-grid .cell:hover { border-color: var(--fg); transform: scale(1.12); }
|
||||
.palette-grid .cell.on { border-color: var(--fg); box-shadow: 0 0 0 1px var(--pane), 0 0 0 2px var(--sel); position: relative; z-index: 1; }
|
||||
|
||||
/* Clear is no colour: a knockout. Checkered, as transparency is everywhere. */
|
||||
.palette .clear,
|
||||
.palette .chip.clear {
|
||||
.palette-grid .clear,
|
||||
.palette-grid .chip.clear {
|
||||
background-color: #fff;
|
||||
background-image:
|
||||
linear-gradient(45deg, #c9c9c5 25%, transparent 25%, transparent 75%, #c9c9c5 75%),
|
||||
|
|
@ -1756,13 +1756,13 @@ button.tl-gap:hover { background: rgba(47, 111, 192, .28); }
|
|||
/* Remap: the map swatch, and the inspector's grid for a remap shape. A slot is
|
||||
shown as what is under the shape will be drawn in; the original is the chip
|
||||
in its corner. */
|
||||
.palette .cell.map,
|
||||
.palette .chip.map {
|
||||
.palette-grid .cell.map,
|
||||
.palette-grid .chip.map {
|
||||
background: linear-gradient(135deg, #3a3f52 0 50%, #e8d9a8 50% 100%);
|
||||
color: #fff; font-size: 11px; line-height: 1; text-shadow: 0 1px 1px rgba(0, 0, 0, .6);
|
||||
}
|
||||
.palette .cell { position: relative; }
|
||||
.palette .cell .badge {
|
||||
.palette-grid .cell { position: relative; }
|
||||
.palette-grid .cell .badge {
|
||||
position: absolute; right: -2px; bottom: -2px;
|
||||
width: 7px; height: 7px;
|
||||
border: 1px solid var(--pane); border-radius: 50%;
|
||||
|
|
@ -1829,35 +1829,81 @@ button.tl-gap:hover { background: rgba(47, 111, 192, .28); }
|
|||
.palette-row .rename { align-self: stretch; padding: 0 7px; border-color: transparent; background: none; }
|
||||
.palette-row .rename:hover:not(:disabled) { border-color: var(--sel); background: #fff; }
|
||||
|
||||
/* The chooser: search, then sections most relevant first, then the classics
|
||||
folded small at the foot. Each row is the playhead's frame in that palette,
|
||||
its strip, its name and where it is from; `use` sits beside it. */
|
||||
/* The list scrolls and nothing else does, so search sits at the top and the
|
||||
shelf at the foot however many palettes there are between them. */
|
||||
.menu.popout:has(.palette-chooser) { width: 300px; display: flex; flex-direction: column; overflow: hidden; }
|
||||
.palette-popout:has(.palette-chooser) { display: flex; flex-direction: column; min-height: 0; flex: 1; }
|
||||
.palette-chooser { display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 0; flex: 1; }
|
||||
.palette-chooser .palette-list { flex: 1 1 auto; min-height: 80px; max-height: none; }
|
||||
.palette-search { width: 100%; }
|
||||
.palette-head {
|
||||
padding: 6px 2px 2px; font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
|
||||
color: var(--dim);
|
||||
}
|
||||
.palette-head:first-child { padding-top: 0; }
|
||||
.palette-row .choose { grid-template-columns: auto 1fr; }
|
||||
.palette-row .choose .text { display: grid; gap: 2px; min-width: 0; }
|
||||
.palette-row .choose .strip { height: 9px; }
|
||||
.palette-row .thumb {
|
||||
width: 48px; height: 36px; object-fit: contain; border-radius: 2px;
|
||||
background: #000; box-shadow: 0 0 0 1px rgba(0, 0, 0, .3);
|
||||
}
|
||||
.palette-row .note {
|
||||
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||
font-size: 10px; color: var(--dim);
|
||||
}
|
||||
.palette-row .use {
|
||||
align-self: stretch; padding: 0 7px; font-size: 10px;
|
||||
border-color: transparent; background: none; opacity: 0;
|
||||
}
|
||||
.palette-row:hover .use, .palette-row .use:focus { opacity: 1; }
|
||||
.palette-row .use:hover:not(:disabled) { border-color: var(--sel); background: #fff; }
|
||||
.palette-editing { display: flex; align-items: center; gap: 6px; min-width: 0; }
|
||||
.palette-editing .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
|
||||
.palette-editing .rename { padding: 0 7px; border-color: transparent; background: none; }
|
||||
.palette-editing .palette-name { flex: 1; min-width: 0; }
|
||||
|
||||
.palette-shelf > summary {
|
||||
cursor: pointer; font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
|
||||
color: var(--dim); padding: 2px;
|
||||
}
|
||||
.palette-shelf .shelf {
|
||||
display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px;
|
||||
padding-top: 4px; max-height: 30vh; overflow: auto;
|
||||
}
|
||||
.palette-shelf .tile {
|
||||
display: grid; gap: 2px; min-width: 0; padding: 3px;
|
||||
border: 1px solid transparent; border-radius: 3px; background: none; text-align: left;
|
||||
}
|
||||
.palette-shelf .tile:hover { background: var(--sunk); border-color: var(--hair); }
|
||||
.palette-shelf .tile .strip { height: 8px; }
|
||||
.palette-shelf .tile .name {
|
||||
font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||
}
|
||||
|
||||
.strip { display: flex; height: 14px; border: 1px solid rgba(0, 0, 0, .35); border-radius: 2px; overflow: hidden; }
|
||||
.strip i { flex: 1; }
|
||||
|
||||
/* On the stage at the playhead. */
|
||||
.on-stage { width: 7px; height: 7px; border-radius: 50%; background: var(--live); }
|
||||
|
||||
/* A palette being edited that the stage is not drawing in here. Information,
|
||||
not alarm: the accent of a selection, not of a warning. */
|
||||
.palette-assets-wrap { position: relative; }
|
||||
.palette-info {
|
||||
position: absolute; top: -3px; right: -5px;
|
||||
width: 13px; height: 13px; border-radius: 50%;
|
||||
display: grid; place-items: center;
|
||||
background: var(--sel); color: #fff;
|
||||
font: italic 600 9px/1 Georgia, serif;
|
||||
cursor: help;
|
||||
box-shadow: 0 0 0 1.5px var(--chrome);
|
||||
|
||||
/* Back to the palette the stage is in, when another is open in the grid. */
|
||||
.palette-grid .back { padding: 1px 4px; font-size: 10px; white-space: nowrap; }
|
||||
/* A slot nothing in the open symbol draws with. */
|
||||
.palette-grid .cell.unused { opacity: .5; }
|
||||
.palette-grid .cell.unused::after {
|
||||
content: ""; position: absolute; inset: 0; pointer-events: none;
|
||||
background: linear-gradient(135deg, transparent 45%, rgba(255, 255, 255, .8) 45% 55%, transparent 55%);
|
||||
}
|
||||
.info-card {
|
||||
position: fixed; z-index: 60;
|
||||
width: 240px; padding: 8px 10px;
|
||||
display: grid; gap: 3px;
|
||||
background: var(--pane); color: var(--fg);
|
||||
font: 11px/1.45 "Lucida Grande", "Segoe UI", system-ui, sans-serif;
|
||||
border: 1px solid var(--sel); border-left-width: 3px; border-radius: 3px;
|
||||
box-shadow: 0 3px 10px rgba(0, 0, 0, .25);
|
||||
cursor: default;
|
||||
}
|
||||
.info-card strong { color: #14395f; }
|
||||
.palette-grid .grid-tools { display: flex; gap: 2px; }
|
||||
.palette-grid .grid-tools button { padding: 0 4px; min-width: 17px; font-size: 11px; }
|
||||
.palette-grid .grid-tools button.on { background: var(--sel-bg); border-color: var(--sel); }
|
||||
|
||||
.view-popout label { display: block; margin-bottom: 8px; }
|
||||
.view-popout label:last-child { margin-bottom: 0; }
|
||||
.view-popout input, .view-popout select { width: 100%; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue