diff clojure/com/aurellem/run/image.clj @ 518:bb4434c5a8f3

generated gameboy palette for gimp for Dylan.
author Robert McIntyre <rlm@mit.edu>
date Sat, 23 Jun 2012 14:27:01 -0500
parents bc24e4d605e9
children fd1ae0047a1a
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/run/image.clj	Fri Jun 22 21:25:47 2012 -0500
     1.2 +++ b/clojure/com/aurellem/run/image.clj	Sat Jun 23 14:27:01 2012 -0500
     1.3 @@ -281,6 +281,21 @@
     1.4        (.dispose))
     1.5      im))
     1.6  
     1.7 +(defn gen-gimp-palette! []
     1.8 +  (let [target
     1.9 +        (File. user-home "proj/vba-clojure/Gameboy-Color.gpl")]
    1.10 +    (spit
    1.11 +     target 
    1.12 +     (apply
    1.13 +      str
    1.14 +      (concat
    1.15 +       ["GIMP Palette\n"
    1.16 +        "Name: GameBoy\n"
    1.17 +        "#\n"]
    1.18 +       (map (fn [[r g b]]
    1.19 +              (format "%3d %3d %3d\n" r g b))
    1.20 +            (sort (set (vals gb-color-map)))))))))
    1.21 +     
    1.22  (def test-image
    1.23    (ImageIO/read
    1.24     (File. user-home "/proj/vba-clojure/images/test-gb-image.png")))
    1.25 @@ -293,9 +308,6 @@
    1.26    (ImageIO/read
    1.27     (File. user-home "/proj/vba-clojure/images/colors-test.png")))
    1.28  
    1.29 -
    1.30 -
    1.31 -
    1.32  (defn rgb->triplet [rgb]
    1.33    (let [r (bit-shift-right (bit-and rgb 0xFF0000) 16)
    1.34          g (bit-shift-right (bit-and rgb 0xFF00)    8)