Draw into the selected symbol
With an instance selected, a finished polygon goes into the symbol it places, its points and frame carried in through clip/inside — which resolves each level, so the frame and matrix are the ones the stage draws with — so the shape lands exactly where it was drawn however the instance is moved, turned, scaled or retimed. Beside any other selected node, or at the top of the open symbol with nothing selected. clip/inside also replaces frame-inside for new symbols, so there is one account of 'which frame is it in there'. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1a42481575
commit
6bec121108
4 changed files with 154 additions and 76 deletions
|
|
@ -5,6 +5,7 @@
|
|||
[arthur.domain.clip :as clip]
|
||||
[arthur.domain.leaf :as leaf]
|
||||
[arthur.domain.node :as node]
|
||||
[arthur.domain.paint :as paint]
|
||||
[arthur.domain.pose :as pose]
|
||||
[arthur.domain.palette :as pal]
|
||||
[arthur.domain.symbol :as symbol]))
|
||||
|
|
@ -266,10 +267,34 @@
|
|||
|
||||
(deftest a-frame-is-carried-down-through-the-instances-a-row-path-names
|
||||
(let [c (nested)
|
||||
[id] (keys (get-in c [:symbols :outer :nodes]))]
|
||||
(is (= [:outer 12] (clip/frame-inside c :outer [] 12)))
|
||||
(is (= [:inner 7] (clip/frame-inside c :outer [id] 12))
|
||||
"the instance starts at 5, so frame 12 outside is frame 7 inside")))
|
||||
[id] (keys (get-in c [:symbols :outer :nodes]))
|
||||
at #(select-keys (clip/inside c nil :outer %1 %2) [:sid :frame])]
|
||||
(is (= {:sid :outer :frame 12} (at [] 12)))
|
||||
(is (= {:sid :inner :frame 7} (at [id] 12))
|
||||
"the instance starts at 5, so frame 12 outside is frame 7 inside")
|
||||
(is (nil? (clip/inside c nil :outer [id] 2))
|
||||
"and before it starts there is no inside to be in")))
|
||||
|
||||
(deftest a-shape-drawn-into-an-instance-lands-where-it-was-drawn
|
||||
(let [u #uuid "00000000-0000-4000-8000-0000000000dd"
|
||||
c (-> (clip/blank)
|
||||
(assoc-in [:symbols :box] {:id :box :frames 30 :nodes {}})
|
||||
(clip/place-symbol nil :main :box 10 u nil)
|
||||
;; moved, turned and doubled, so nothing lines up by accident
|
||||
(update-in [:symbols :main :nodes u :channels] merge
|
||||
{[:xform :pos] (ch/framed [40 20])
|
||||
[:xform :rot] (ch/framed (/ js/Math.PI 2))
|
||||
[:xform :scale] (ch/framed [2 2])}))
|
||||
drawn [100 50 140 50 120 90]
|
||||
{:keys [sid frame pts]} (clip/drawn-inside c nil :main [u] 16 drawn)
|
||||
c (paint/new-shape c sid :shape frame pts :brow)
|
||||
[op] (filter #(= [u :shape] (:node %))
|
||||
((clip/resolver c nil pal/index-of :main) 16))]
|
||||
(is (= :box sid))
|
||||
(is (= 6 frame) "frame 16 of main is frame 6 of an instance placed at 10")
|
||||
(is (every? #(< (js/Math.abs %) 1e-9)
|
||||
(map - drawn (take 6 (array-seq (:pts op)))))
|
||||
"resolved back out through the instance, it is exactly what was drawn")))
|
||||
|
||||
(deftest adopting-symbols-renames-what-collides
|
||||
(let [here (nested)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue