Skip to content

Instantly share code, notes, and snippets.

@halcat0x15a
Created September 7, 2013 08:55
Show Gist options
  • Save halcat0x15a/6474004 to your computer and use it in GitHub Desktop.
Save halcat0x15a/6474004 to your computer and use it in GitHub Desktop.
(defn points [^BufferedImage image ^BufferedImage screen]
(let [width (.getWidth image)
height (.getHeight image)
xrange (range width)
yrange (range height)]
(for [points
(for [sx (range (- (.getWidth screen) width))
sy (range (- (.getHeight screen) height))]
(for [tx xrange
ty yrange]
[sx sy tx ty]))
:when (every? (fn [[sx sy tx ty]]
(= (.getRGB screen (+ sx tx) (+ sy ty))
(.getRGB image tx ty)))
points)
[x y _ _] points]
[(+ x (/ width 2)) (+ y (/ height 2))])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment