34 lines
1.7 KiB
Clojure
34 lines
1.7 KiB
Clojure
(ns arthur.domain.paint-test
|
|
(:require [cljs.test :refer [deftest is]]
|
|
[arthur.demo :as demo]
|
|
[arthur.domain.channel :as channel]
|
|
[arthur.domain.leaf :as leaf]
|
|
[arthur.domain.node :as node]
|
|
[arthur.domain.paint :as paint]
|
|
[arthur.domain.symbol :as symbol]))
|
|
|
|
(defn- geometry [clip]
|
|
(get-in clip [:symbols :main :nodes :paint-test :channels paint/geometry]))
|
|
|
|
(deftest drawing-keys-hold-and-tween-on-the-symbol-clock
|
|
(let [a [10 10 30 10 20 30]
|
|
c0 (paint/new-shape demo/clip :main :paint-test 3 a :brow)
|
|
c1 (paint/add-key c0 :main :paint-test 9)
|
|
c2 (paint/set-vertex c1 :main :paint-test 9 0 [22 10])
|
|
c3 (paint/add-key c2 :main :paint-test 15)
|
|
c4 (paint/set-vertex c3 :main :paint-test 15 0 [34 10])
|
|
held (geometry c4)
|
|
mixed-clip (update-in c4 [:symbols :main :nodes :paint-test]
|
|
node/set-segment-interp paint/geometry 9 :linear)
|
|
mixed (geometry mixed-clip)]
|
|
(is (= [3 229] (get-in c2 [:symbols :main :nodes :paint-test :span])))
|
|
(is (= a (channel/value-at held 8)))
|
|
(is (= 10 (first (channel/value-at held 8))))
|
|
(is (= 22 (first (channel/value-at held 9))))
|
|
(is (= 10 (first (channel/value-at mixed 6))) "the first gap cuts")
|
|
(is (= 28 (first (channel/value-at mixed 12))) "the second gap tweens")
|
|
(is (empty? (channel/problems mixed)))
|
|
;; The demo's root is exposed on 2s. Paint at frame 3 must still appear at 3.
|
|
(is (some #(= :paint-test (:node %))
|
|
(symbol/eval-frame (get-in c2 [:symbols :main]) 3)))
|
|
(is (= mixed-clip (leaf/clip :c1 (leaf/leaves :c1 mixed-clip))))))
|