-
-
Save odekopoon/7fda94171c583d14ca92 to your computer and use it in GitHub Desktop.
seesawの警告は表示しないように
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
(ns stagbeetle.core | |
(:gen-class) | |
(:use [seesaw.core] | |
[seesaw.graphics])) | |
(set! *warn-on-reflection* true) | |
(import (java.awt.image BufferedImage | |
WritableRaster) | |
(java.awt Color | |
Graphics)) | |
(def frm (frame :title "stagbeetle")) | |
(def cnv (canvas)) | |
(def ^BufferedImage img (buffered-image 640 480 BufferedImage/TYPE_INT_ARGB)) | |
(defn draw-stripe [^WritableRaster ras | |
i o c1 c2] | |
(dotimes [y (.getHeight ras)] | |
(dotimes [x (.getWidth ras)] | |
(if (even? (quot (+ o x) i)) | |
(.setPixel ras x y (int-array c1)) | |
(.setPixel ras x y (int-array c2))))) | |
nil) | |
(defn paint [c ^Graphics g] | |
(try (draw g (rect 0 0 (width c) (height c)) | |
(style :background :black)) | |
(.drawImage g img 0 0 nil))) | |
(defn init [] | |
(native!) | |
(config! cnv :size [640 :by 480]) | |
(config! cnv :paint paint) | |
(config! frm :content cnv)) | |
(defn -main | |
[& args] | |
(init) | |
(config! frm :on-close :dispose) | |
(let [start (System/currentTimeMillis)] | |
(draw-stripe (.getRaster img) 50 0 [0 0 255 255] [255 255 255 255]) | |
(println "eplaced:" (format "%.3f" (float (/ (- (System/currentTimeMillis) start) 1000))))) | |
(-> frm pack! show!)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment