K keys or draws on, shift-K draws blank, = and - change a hold

In a lane, K is Flash's F6: a copy of the drawing showing, taking over
from the playhead, or on the next frame when the playhead is on a
drawing's first one, so pressing it again and again draws on. Shift-K is
F7, the same with an empty drawing. Elsewhere K is Blender's I: what is
animated, or else position, turn and scale, keyed at the playhead.
= and - lengthen and shorten the selected hold by a frame, as in Harmony.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Olive Vaughn 2026-10-10 20:17:30 -04:00
parent e96464459d
commit 246b6d6468
6 changed files with 179 additions and 1 deletions

View file

@ -210,6 +210,19 @@
(:segments c) (update :segments dissoc f))
:else (ch/framed v))))))
(defn key-at
"Key `n` on its own frame `f` with the values it has there: every channel
already keyed, or its position, turn and scale when none is — Blender's I.
A channel with a key at `f` already keeps it."
[n f store]
(let [chs (channels n)
keyed (keep (fn [[path c]] (when (:keys c) path)) chs)]
(reduce (fn [n path]
(if (contains? (:keys (get (channels n) path)) f) n (toggle-key n path f store)))
n
(or (seq keyed)
(filter #(contains? chs %) [[:xform :pos] [:xform :rot] [:xform :scale]])))))
(defn set-segment-interp
"Choose how channel `path`'s key at `left` leads to the next one: `:hold` cuts
there, `:linear` tweens. The same for a drawing's points as for a transform —

View file

@ -778,6 +778,51 @@
nodes (assoc nodes id (held id drawing-id at))]
(claim c sid nodes id extent remainder-id)))))
(defn drawing-at
"A new drawing in lane `sid` from frame `f`, as Flash's F6 and F7 make one:
a copy of the drawing showing there when `copy?`, an empty one when not.
IT TAKES OVER FROM `f`. Inside a hold, the held cel ends at `f` and the new
one has the rest of it, so the timing already there is kept and only the
drawing changes. In a gap it runs to the next cel; past the last one it is one
frame. On a cel's first frame there is a drawing starting there already, so
the new one goes on the frame after — pressing F6 again and again draws on,
one frame at a time — and shows the drawing it came after.
The copy is of the content, shallow, as `duplicate-drawing`'s is, under a name
of its own. `:frame` in the result is where it landed."
[clip sid f new-id drawing-id {:keys [copy? extent] :or {extent :keep}}]
(let [nodes (get-in clip [:symbols sid :nodes])
cels (symbol/children nodes)
lo-of #(first (node/placed-span %))
hi-of #(second (node/placed-span %))
on (some #(when (= f (lo-of %)) %) cels)
f (if on (inc f) f)
holding (some #(when (< (lo-of %) f (hi-of %)) %) cels)
shown (or holding on (last (filter #(<= (hi-of %) f) cels)))
next-lo (some #(when (<= f (lo-of %)) (lo-of %)) cels)
from (when copy? (some-> shown node/source))]
(cond
(not (and (integer? f) (not (neg? f)))) {:refused "a position is a nonnegative whole frame"}
(contains? nodes new-id) {:refused "the new clip ID is already used"}
(clip/symbol clip drawing-id) {:refused "the new drawing ID is already used"}
(and copy? (not (clip/symbol clip from))) {:refused "there is no drawing here to copy"}
:else
(let [c (assoc-in clip [:symbols drawing-id]
(if from
;; Its own name: it is a new drawing, and two of one
;; name in the library is a question nobody asked.
(assoc (clip/symbol clip from) :id drawing-id :name (name drawing-id))
{:id drawing-id :name (name drawing-id) :frames 1 :nodes {}}))]
(if (= f next-lo)
;; A cel starts right here, so there is no room: make some.
(place c sid new-id drawing-id f extent true)
(let [end (cond holding (hi-of holding) next-lo next-lo :else (inc f))
nodes (cond-> (assoc nodes new-id (assoc (held new-id drawing-id f) :span [0 (- end f)]))
holding (assoc (:id holding) (edged holding :out f)))]
(let [result (finish c sid nodes new-id extent)]
(cond-> result (:clip result) (assoc :frame f)))))))))
(defn make-unique
"Point clip `id` at a private copy of its content, leaving every other
clip of that drawing sharing the original.

View file

@ -30,6 +30,7 @@
[arthur.domain.palette :as pal]
[arthur.domain.pick :as pick]
[arthur.domain.span :as span]
[arthur.domain.symbol :as symbol]
[arthur.events.edit :as edit]
[arthur.domain.paint :as paint]
[arthur.events.playback :as playback]
@ -362,6 +363,63 @@
result (span/extend-hold clip sid id delta {:extent (or extent :keep)})]
(apply-command db sid result [::extend-hold delta :grow-symbol]))))
(defn lane-here
"The lane the playhead is in, as `nest/inside` answers it with its `:path`
from the open symbol: the nearest lane the selection is in, at any depth —
so a stroke just drawn in a cel counts as being in that cel's lane — or else
the lane the selection would draw into. Nil where there is none."
[db]
(let [{clip :clip st :store} (store/entry (:clip/current db))
open (get-in db [:ui :open])
f (editing-frame db clip)
[kind _ _ path :as selection] (get-in db [:ui :selection])
lane-at (fn [p]
(when-let [in (nest/inside clip st open p f)]
(when (symbol/lane? (clip/symbol clip (:sid in)))
(assoc in :path p))))]
(or (when (= :node kind)
(some #(lane-at (pop %)) (take-while seq (iterate pop (vec path)))))
(let [t (creation/target clip st open selection f)]
(when (= :lane (:kind t)) (lane-at (:path t)))))))
(rf/reg-event-fx
::drawing-here
;; K and ⇧K in a lane: see `span/drawing-at`. The new cel is selected and the
;; playhead put on it, because it is there to be drawn in.
(fn [{:keys [db]} [_ copy?]]
(let [clip (:clip (store/entry (:clip/current db)))
{:keys [sid frame path time]} (lane-here db)
id (random-uuid)
result (if sid
(span/drawing-at clip sid frame id (clip/fresh-id clip)
{:copy? copy? :extent :grow-symbol})
{:refused "select a lane, or a drawing in one"})]
(if-let [why (:refused result)]
{:db (assoc-in db [:project :status] why)}
(cond-> {:db (-> db
(edit/transaction (constantly (:clip result)))
(selected [:node sid id (conj path id)]))}
time (assoc :dispatch [::playback/seek
(js/Math.ceil (+ (:at time) (/ (:frame result) (:rate time))))]))))))
(rf/reg-event-db
::key-selected
;; K on anything that is not in a lane: Blender's I.
(fn [db _]
(let [{clip :clip st :store} (store/entry (:clip/current db))
f (editing-frame db clip)
places (keep (fn [[kind _ _ path]]
(when (and (= :node kind) (seq path))
(nest/placement clip st (get-in db [:ui :open]) path f)))
(get-in db [:ui :selections]))]
(if (empty? places)
(assoc-in db [:project :status] (if (seq (get-in db [:ui :selections]))
"what is selected is not on screen at this frame"
"select something to key"))
(edit/edit db #(reduce (fn [c {:keys [sid id frame]}]
(update-in c [:symbols sid :nodes id] node/key-at frame st))
% places))))))
(rf/reg-event-fx
::retry
(fn [{:keys [db]} _]

View file

@ -13,7 +13,7 @@
key with two meanings, and they are told apart by the hand rather than by a
mode: tapped it plays, held and dragged on the stage it pans, as in Photoshop.
THE KEYS ARE BLENDER'S, then Resolve's, then Flash's. WASD repeats the arrows
THE KEYS ARE BLENDER'S, then Resolve's, then Flash's and Harmony's. WASD repeats the arrows
for a hand that stays on the left of the keyboard while the other holds the
pen. Letters are matched by where they are on the keyboard, not by what they
type, so WASD is WASD on any layout and ⌥O is O on a Mac too."
@ -67,6 +67,13 @@
{:label "Onion skin" :keys ["alt+o"]
:run #(let [on? (get-in % [:ui :onion (:clip/current %) (get-in % [:ui :open]) :on?])]
[::layout/onion :on? (not on?)])}]]
["Animate"
[{:label "Key here" :keys ["k"]
:note "in a lane, a copy of the drawing from the playhead on"
:run #(if (ui/lane-here %) [::ui/drawing-here true] [::ui/key-selected])}
{:label "Blank drawing here" :keys ["shift+k"] :run (constantly [::ui/drawing-here false])}
{:label "Hold a frame longer" :keys ["=" "+"] :run (constantly [::ui/extend-hold 1 :grow-symbol])}
{:label "Hold a frame shorter" :keys ["-"] :run (constantly [::ui/extend-hold -1])}]]
["Draw"
[{:label "Select" :keys ["v"] :run (constantly [::ui/tool-key "v"])}
{:label "Pen" :keys ["p"] :run (constantly [::ui/tool-key "p"])}