Skip to content

Instantly share code, notes, and snippets.

@cassiel
Created September 18, 2012 20:48
Show Gist options
  • Save cassiel/3745794 to your computer and use it in GitHub Desktop.
Save cassiel/3745794 to your computer and use it in GitHub Desktop.
Puffdraw Bad Code 2
(defn paint
"Paint does the work. Iterate through the circular queue of states, drawing
a fat line from each point to the next (if button down)."
[me]
(...
(letfn [(iter [i last-x last-y]
((let [{:keys [button x y]} (nth points i)]
...
(.move_to g last-x last-y)
(.line_to g x y)
(.stroke g))
(when (< i (- TRAIL-LENGTH 1))
(recur (inc i) x y))))]
(iter 1
(:x (first points))
(:y (first points))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment