-
-
Save kmizu/6484608 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 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
TODO: Type Hints http://clojure.org/java_interop#Java%20Interop-Type%20Hints
で高速化できないか実験してみる。