Advertisement
Guest User

Untitled

a guest
Nov 7th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (ns creative-playground.sketches.eye
  2.   (:require [quil.core :as q]
  3.             [quil.middleware :as m]))
  4.  
  5. ; define colors below
  6.  
  7. ; diffrent diameter offsets down there
  8. (def diam-offset [{:x 1 :y 1}
  9.                   {:x 2 :y 2}
  10.                   {:x 3 :y 2}
  11.                   {:x 3 :y 4}
  12.                   {:x 5 :y 4}])
  13.  
  14. (defn setup []
  15.   (q/frame-rate 30)
  16.   (q/smooth)
  17.   (q/background 180)
  18.   {:diam 0
  19.    :direction 1})
  20.  
  21. (defn update-state [state]
  22.   (let [diam (+ (:diam state) (* (:direction state)))]
  23.   (cond
  24.     (> diam 500) {:direction -1
  25.                   :diam diam}
  26.     (< diam 0) {:direction 1
  27.                 :diam diam}
  28.     :else {:direction (:direction state)
  29.            :diam diam})))
  30.  
  31. (defn draw-state [state]
  32.  
  33.   (q/background 44 62 80)
  34.   (q/stroke  44 62 80)
  35.   (q/stroke-weight 5)
  36.   (q/fill 127 140 141)
  37.  
  38.   (let [cent-x (/ (q/width) 2)
  39.         cent-y (/ (q/height) 2)
  40.         diam   (:diam state)]
  41.    
  42.     (doseq [pos diam-offset]
  43.       (q/ellipse cent-x cent-y (/ diam (:x pos)) (/ diam (:y pos))))))
  44.  
  45. (q/defsketch eye
  46.   :title "Eyes"
  47.   :size [500 500]
  48.   :setup setup
  49.   :draw draw-state
  50.   :update update-state
  51.   :features [:keep-on-top]
  52.   :middleware [m/fun-mode])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement