Unify lane symbol creation and palette automation
This commit is contained in:
parent
15deaea19e
commit
a834ccb1e2
13 changed files with 176 additions and 121 deletions
|
|
@ -4,7 +4,8 @@
|
|||
in the renderer reads. These assert the parts of that claim that could silently
|
||||
stop being true."
|
||||
(:require [cljs.test :refer [deftest is testing]]
|
||||
[arthur.domain.channel :as ch]))
|
||||
[arthur.domain.channel :as ch]
|
||||
[arthur.domain.palette :as pal]))
|
||||
|
||||
;; ---- the three shapes read the same way ----
|
||||
|
||||
|
|
@ -392,6 +393,21 @@
|
|||
(is (= {:from :day :to :night :t 0.5}
|
||||
(ch/value-at blend 5 nil)))))
|
||||
|
||||
(deftest palette-choice-channels-blend-editor-uuid-identities
|
||||
(let [day (random-uuid)
|
||||
night (random-uuid)
|
||||
blend (assoc (ch/keyed {0 day 10 night} :linear) :semantic :palette)]
|
||||
(is (empty? (ch/problems blend)))
|
||||
(is (= {:from day :to night :t 0.5}
|
||||
(ch/value-at blend 5 nil)))))
|
||||
|
||||
(deftest palette-choice-channels-can-blend-from-inherit
|
||||
(let [night (random-uuid)
|
||||
blend (assoc (ch/keyed {0 pal/inherit 10 night} :linear) :semantic :palette)]
|
||||
(is (empty? (ch/problems blend)))
|
||||
(is (= {:from pal/inherit :to night :t 0.5}
|
||||
(ch/value-at blend 5 nil)))))
|
||||
|
||||
(deftest numeric-channels-can-ramp-between-keys
|
||||
(let [c (ch/keyed {0 0.0, 10 1.0} :linear)
|
||||
cursor (ch/cursor c nil)]
|
||||
|
|
|
|||
|
|
@ -406,3 +406,32 @@
|
|||
(is (nil? (:refused extended)) (:refused extended))
|
||||
(is (= [0 6] (node/placed-span
|
||||
(get-in extended [:clip :symbols :palettes :nodes :change]))))))
|
||||
|
||||
(deftest a-blank-palette-symbol-can-tween-from-inherit-to-an-editor-palette
|
||||
(let [day (random-uuid)
|
||||
night (random-uuid)
|
||||
palette (fn [id color]
|
||||
{:id id :name (str id) :slots [{:hex color} {:hex color}]})
|
||||
choice (assoc (ch/keyed {0 pal/inherit 4 night} :linear) :semantic :palette)
|
||||
document {:fps 30 :width 20 :height 20
|
||||
:palettes {day (palette day "#000000")
|
||||
night (palette night "#ffffff")}
|
||||
:default-palette day
|
||||
:symbols
|
||||
{:main {:id :main :frames 5 :palette day :palette-track :palettes
|
||||
:nodes {}}
|
||||
:palettes {:id :palettes :type :palette-track :display :lane :frames 5
|
||||
:nodes {:change {:id :change :kind :instance :z "a1"
|
||||
:source {:symbol :transition}
|
||||
:span [0 5] :time {:at 0}
|
||||
:channels {[:palette] choice}}}}
|
||||
:transition {:id :transition :name "palette transition"
|
||||
:type :palette :frames 1 :nodes {}}}}
|
||||
context (pal/compile document)
|
||||
resolve (clip/resolver document :main nil context nil)]
|
||||
(is (empty? (clip/problems document)))
|
||||
(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))))))
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
[arthur.domain.history :as history]
|
||||
[arthur.domain.leaf :as leaf]
|
||||
[arthur.domain.node :as node]
|
||||
[arthur.domain.palette :as pal]
|
||||
[arthur.domain.sequence-test :as fixture]
|
||||
[arthur.domain.span :as span]
|
||||
[arthur.events.ui :as ui]
|
||||
|
|
@ -71,6 +72,40 @@
|
|||
(vals (get-in saved [:symbols :main :nodes]))))
|
||||
"claiming the frame leaves no overlapping cel"))))
|
||||
|
||||
(deftest double-click-creation-uses-the-lane-and-pointer-frame
|
||||
(let [doc (fixture/document)
|
||||
id (store/install! {:clip doc :store {}} "double-click-new-symbol")]
|
||||
(reset! rf-db/app-db {:clip/current id :paint/revision 0
|
||||
:ui {:open :main} :playback {:frame 0}})
|
||||
(rf/dispatch-sync [::ui/new-symbol-at 5 [:node :main nil []]])
|
||||
(let [saved (:clip (store/entry id))
|
||||
[_ sid instance-id] (get-in @rf-db/app-db [:ui :selection])
|
||||
instance (get-in saved [:symbols sid :nodes instance-id])]
|
||||
(is (= :main sid))
|
||||
(is (= [5 6] (node/placed-span instance)))
|
||||
(is (= 1 (clip/frames saved (node/source instance))))
|
||||
(is (zero? (get-in @rf-db/app-db [:playback :frame]))
|
||||
"the pointer frame, not the playhead, chooses the new cel's time"))))
|
||||
|
||||
(deftest the-same-double-click-command-creates-a-palette-symbol-on-the-palette-row
|
||||
(let [doc (clip/blank)
|
||||
id (store/install! {:clip doc :store {}} "double-click-palette-symbol")]
|
||||
(reset! rf-db/app-db {:clip/current id :paint/revision 0
|
||||
:ui {:open :main} :playback {:frame 0}})
|
||||
(rf/dispatch-sync [::ui/new-symbol-at 5
|
||||
[:arthur.ui.timeline/palette-track :main]])
|
||||
(let [saved (:clip (store/entry id))
|
||||
track-id (get-in saved [:symbols :main :palette-track])
|
||||
[_ sid instance-id] (get-in @rf-db/app-db [:ui :selection])
|
||||
instance (get-in saved [:symbols sid :nodes instance-id])
|
||||
source (node/source instance)]
|
||||
(is (= track-id sid))
|
||||
(is (= :palette-track (get-in saved [:symbols track-id :type])))
|
||||
(is (= :palette (get-in saved [:symbols source :type])))
|
||||
(is (= [5 6] (node/placed-span instance)))
|
||||
(is (= pal/inherit
|
||||
(get-in instance [:channels [:palette] :value]))))))
|
||||
|
||||
(deftest a-new-lane-uses-the-symbol-selected-at-the-playhead
|
||||
(let [doc (clip/blank)
|
||||
id (store/install! {:clip doc :store {}} "nested-new-lane")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue