我正在尝试10 PRINT
用 Quil 编写代码。我尝试从使用 luna的推特帖子https://twitter.com/ACharLuk/status/913094845505445890转换此代码
这是我的代码
(ns tenprint.core
(:require [quil.core :as q]
[quil.middleware :as m]))
(defn setup []
(q/frame-rate 30)
(q/color-mode :hsb)
{:x 0
:y 0
:scale 20
}
)
(defn update-state [state]
(let [x (:x state) y (:y state) s (:scale state)]
{
:x (do (+ x s) ((if (>= x q/width) 0)))
:y (do (if (>= x q/width) (+ y s)) (if (>= x q/height) (+ y s)))
:scale (+ s 0)
}
)
)
(defn draw-state [state]
(q/background 0)
(q/stroke 255)
;(q/line 0 10 10 0)
(let [x (:x state) y (:y state) s (:scale state)]
(if (> (rand) 0.5)
(q/line x y (+ x s) (+ y s))
(q/line x (+ y s) (+ x s) y)
)
)
)
(q/defsketch tenprint
:title "10PRINT"
:size [500 500]
:setup setup
:update update-state
:draw draw-state
:settings #(q/smooth 2)
:features [:keep-on-top]
:middleware [m/fun-mode]
)
它只是看起来像这样。我试图拆分状态的更新,但它说你不能有重复的变量要更新
谢谢你。