Created
July 11, 2010 10:56
-
-
Save chrisschreiner/471459 to your computer and use it in GitHub Desktop.
This file contains 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 inside-byte [v] | |
(cond | |
(< v 0) 0 | |
(> v 255) 255 | |
:else v)) | |
(defn darker- [color fraction] | |
(let [fr (- 1.0 fraction) | |
red (inside-byte (-> (.getRed color) (* fr) Math/round)) | |
green (inside-byte (-> (.getGreen color) (* fr) Math/round)) | |
blue (inside-byte (-> (.getBlue color) (* fr) Math/round)) | |
alpha (.getAlpha color)] | |
(Color. red green blue alpha))) |
When I type-hint the return, it works
(defn inside-byte [v](cond
%28< v 0%29 0
%28> v 255%29 255
:else %28int v%29))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No matching ctor found for class java.awt.Color
[Thrown class java.lang.IllegalArgumentException]