Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Creates a 800x600 field and (is intended) to draw a new 10x10 rectangle after each mouse click
- ; Nevertheless..
- (ns sample.core
- (:use quil.core))
- (def cell-size 10)
- (def w (* 80 cell-size))
- (def h (* 60 cell-size))
- (def X (atom 0))
- (def Y (atom 0))
- (defn draw []
- (do
- (stroke-weight 1)
- (stroke 0)
- (fill 255)
- (swap! X + cell-size)
- (swap! Y + cell-size)
- (rect @X @Y cell-size cell-size)))
- (defn mouse-handler [] ; We never see this happen
- (redraw) ; This block isn't call at all: After mouse click we neither see the redraw happen
- (println "abacaba") ; Nor any output.
- )
- (defn setup []
- (background 40)
- (no-loop)) ; https://github.com/quil/quil/wiki/no~loop
- (defn field []
- (sketch
- :title "sample"
- :draw draw
- :setup setup
- :mouse-pressed mouse-handler ; None of 3 types of possible handlers gives the correct result
- :size [w h]))
- (field)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement