Advertisement
Guest User

Untitled

a guest
Nov 8th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (ns creative-playground.sketches.helix
  2.   (:require [quil.core :as q]
  3.             [quil.middleware :as m]))
  4.  
  5. (defn col-ang [color angle]
  6.   {:color color :angle angle})
  7.  
  8. (defn setup []
  9.   (q/frame-rate 30)
  10.   (q/color-mode :hsb)
  11.   (col-ang 0 0))
  12.  
  13. (defn moving-circle [x angle diam]
  14.   (q/with-translation [(/ (q/width) 2)
  15.             0]
  16.  
  17.     (let[y (* 80 (q/sin (+ x angle)))]
  18.       (q/ellipse y x diam diam))))
  19.  
  20. (defn update-state [state]
  21.   (col-ang
  22.     (mod (+ (:color state) 0.7) 255)
  23.     (+ (:angle state) 0.05)))
  24.  
  25. (defn draw-state [state]
  26.   (q/background 240)
  27.   (q/fill 255 0 (:color state))
  28.  
  29.   (let [angle (:angle state)]
  30.     (doseq [x (range -30 300 15)]
  31.       (moving-circle x (+ angle 45) 15)
  32.       (moving-circle x (+ angle 90) 10)
  33.       (moving-circle x (+ angle 135) 15)
  34.       (moving-circle x (+ angle 180) 15)
  35.       (moving-circle x angle 25))))
  36.  
  37. (q/defsketch helix
  38.   :title "helix like moving object."
  39.   :size [500 300]
  40.   :setup setup
  41.   :update update-state
  42.   :draw draw-state
  43.   :features [:keep-on-top]
  44.   :middleware [m/fun-mode])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement