Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns creative-playground.sketches.helix
- (:require [quil.core :as q]
- [quil.middleware :as m]))
- (defn col-ang [color angle]
- {:color color :angle angle})
- (defn setup []
- (q/frame-rate 30)
- (q/color-mode :hsb)
- (col-ang 0 0))
- (defn moving-circle [x angle diam]
- (q/with-translation [(/ (q/width) 2)
- 0]
- (let[y (* 80 (q/sin (+ x angle)))]
- (q/ellipse y x diam diam))))
- (defn update-state [state]
- (col-ang
- (mod (+ (:color state) 0.7) 255)
- (+ (:angle state) 0.05)))
- (defn draw-state [state]
- (q/background 240)
- (q/fill 255 0 (:color state))
- (let [angle (:angle state)]
- (doseq [x (range -30 300 15)]
- (moving-circle x (+ angle 45) 15)
- (moving-circle x (+ angle 90) 10)
- (moving-circle x (+ angle 135) 15)
- (moving-circle x (+ angle 180) 15)
- (moving-circle x angle 25))))
- (q/defsketch helix
- :title "helix like moving object."
- :size [500 300]
- :setup setup
- :update update-state
- :draw draw-state
- :features [:keep-on-top]
- :middleware [m/fun-mode])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement