Colour cycling is a looping symbol of one remap

A three-frame symbol holding one remap shape whose map turns a step a
frame, placed looping, cycles what is under it and only under its shape,
as Deluxe Paint cycled a range. Nothing was made for it, so this pins
that a symbol's remap reaches what the instance is drawn over.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Olive Vaughn 2026-11-24 11:47:13 -05:00
parent 943dc93d7d
commit 1f1e16b411

View file

@ -651,6 +651,38 @@
(is (= [a b c p] (clip/atop [a b c] [] p)) "the open symbol is on top of everything")
(is (= [a b c p] (clip/atop [a b c] [:empty] p)))))
(deftest a-looping-symbol-of-one-remap-cycles-what-is-under-it
;; Colour cycling, as Deluxe Paint did it, with nothing made for it: a
;; three-frame symbol holding one remap shape whose map turns a step a frame,
;; placed looping over what it cycles. The symbol draws into the buffer the
;; stage is drawn into, so its remap reaches what is under the instance —
;; and only under its shape.
(let [sq (fn [x0 y0 x1 y1] [x0 y0 x1 y0 x1 y1 x0 y1])
doc (-> (clip/blank)
(paint/new-shape :main :a 0 (sq 0 0 10 10) 1)
(paint/new-shape :main :b 0 (sq 10 0 20 10) 2)
(paint/new-shape :main :c 0 (sq 20 0 30 10) 3)
(paint/new-shape :main :d 0 (sq 30 0 40 10) 1)
(assoc-in [:symbols :main :nodes :a :z] "a")
(assoc-in [:symbols :main :nodes :b :z] "b")
(assoc-in [:symbols :main :nodes :c :z] "c")
(assoc-in [:symbols :main :nodes :d :z] "d")
(assoc-in [:symbols :spin]
{:id :spin :frames 3
:nodes {:glass {:id :glass :kind :poly :z "a"
:channels {[:geom :pts] (ch/framed (sq 0 0 30 10))
[:style :color] (ch/keyed {0 [:remap {}]
1 [:remap {1 2 2 3 3 1}]
2 [:remap {1 3 2 1 3 2}]} :hold)}}}})
(assoc-in [:symbols :main :nodes :spun]
{:id :spun :kind :instance :z "z" :source {:symbol :spin}
:playback {:in 0 :speed 1 :end :loop}}))
res (clip/resolver doc :main nil (pal/compile doc) nil)
at (fn [f] (let [r (raster/draw-ops! (raster/clear! (raster/make 320 200) 0) (res f))]
(mapv #(aget (:buf r) (+ % (* 5 320))) [5 15 25 35])))]
(is (= [[1 2 3 1] [2 3 1 1] [3 1 2 1] [1 2 3 1] [2 3 1 1]] (mapv at (range 5)))
"the three stripes under it turn and come round again; the fourth, outside it, does not")))
(deftest a-remap-shape-lights-what-is-under-it-and-nothing-else
;; A flashlight: a circle that draws nothing of its own, and draws what is
;; already under it in other slots of the palette.