Skip to content

Commit

Permalink
Create colors from any number, not only ints
Browse files Browse the repository at this point in the history
  • Loading branch information
paraseba committed Dec 9, 2011
1 parent f4a63be commit bea1d2d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/types.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

(defn rgb
([r g b]
{:pre [(every? integer? [r g b])] :post [(= Color (class %))]}
(letfn [(limit [x] (max 0 (min x 255)))]
{:pre [(every? number? [r g b])] :post [(= Color (class %))]}
(letfn [(limit [x] (max 0 (min (int x) 255)))]
(Color. (limit r) (limit g) (limit b))))
([s]
{:pre [(or (string? s) (keyword? s) (symbol? s))]
Expand Down

0 comments on commit bea1d2d

Please sign in to comment.