-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathday25_viz.clj
51 lines (37 loc) · 1.12 KB
/
day25_viz.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
(ns day25-viz
(:require aoc
day12
day12-viz
day25
[quil.core :as q]
[quil.middleware :as m]))
(def instructions (vec (aoc/read-input 25 day12/parse-line)))
(def init-state {:instrs instructions
:len (count instructions)
:line 0
:done? false
:out []
:regs {:a 196 :b 0 :c 0 :d 0}})
(def line-height 20)
(defn setup []
(q/frame-rate 15)
(q/smooth)
(q/background 15 15 33)
(q/text-font (q/create-font "Iosevka Extended" (* 0.7 line-height)))
(q/text-align :right :center)
init-state)
(defn draw-table [{:keys [instrs line regs out]}]
(day12-viz/draw-instructions instrs)
(day12-viz/draw-registers regs)
(day12-viz/draw-triangle line)
(day12-viz/draw-out out)
#_(q/save-frame "/tmp/imgs/day25-####.jpg")
(when (> (count out) 15)
(q/exit)))
(q/sketch
:size [(* 16 line-height) (* 32 line-height)]
:setup #'setup
:update #'day25/run-instruction
:draw #'draw-table
:middleware [m/fun-mode])
; convert -layers optimize -delay 8 /tmp/imgs/day25*.jpg imgs/day25.gif