Skip to content

Instantly share code, notes, and snippets.

@pcomans
Created July 22, 2011 19:49
Show Gist options
  • Save pcomans/1100269 to your computer and use it in GitHub Desktop.
Save pcomans/1100269 to your computer and use it in GitHub Desktop.
(defn xors
"Returns bitwise XORs"
[max-x max-y]
(for [x (range max-x)
y (range max-y)]
[x y (bit-xor x y)]))
(def frame (java.awt.Frame.))
(.setVisible frame true)
(.setSize frame (java.awt.Dimension. 512 512))
(def gfx (.getGraphics frame))
(doseq [[x y xor] (xors 512 512)]
(.setColor gfx (java.awt.Color. (mod xor 256) (mod xor 256) (mod xor 256)))
(.fillRect gfx x y 1 1))
(doseq [[x y xor] (xors 512 512)
grey (mod xor 256)]
(.setColor gfx (java.awt.Color. grey grey grey))
(.fillRect gfx x y 1 1))
(doseq [[x y xor] (xors 512 512)]
(let [grey (mod xor 256)]
(.setColor gfx (java.awt.Color. grey grey grey))
(.fillRect gfx x y 1 1)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment