Skip to content

Instantly share code, notes, and snippets.

@kmizu
Forked from halcat0x15a/pointns.clj
Created September 8, 2013 13:10
Show Gist options
  • Save kmizu/6484608 to your computer and use it in GitHub Desktop.
Save kmizu/6484608 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))])))
@kmizu
Copy link
Author

kmizu commented Sep 8, 2013

TODO: Type Hints http://clojure.org/java_interop#Java%20Interop-Type%20Hints
で高速化できないか実験してみる。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment