Created
October 11, 2009 01:58
-
-
Save JonathanSmith/207321 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn mouse-click [[x y] state] | |
(let [ul (:upper-left state) | |
lr (:lower-right state) | |
coord (map / [x y] (:dim state))] | |
(update-bounds | |
(assoc state | |
:offset (map + ul (map * coord (map - lr ul))))))) | |
(defn key-press [key s] | |
(if-let [dispatch-fn ({:Z (fn [state] | |
(update-bounds | |
(assoc state | |
:zoom (* 2 (:zoom state))))) | |
:X (fn [state] | |
(update-bounds | |
(assoc state | |
:zoom (/ (:zoom state) 2))))} key)] | |
(dispatch-fn s) | |
s)) | |
. | |
. | |
. | |
(start | |
{:init init, :reshape reshape, :update update, :display display, :key-press key-press :mouse-click mouse-click} | |
(reset-fractal {:upper-left [-2.0 1.0] :lower-right [1.0 -1.0] :zoom 1 :offset [-0.5 0]})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment