2012-10-05 02:01:20 +00:00
|
|
|
|
2013-02-10 11:58:40 +00:00
|
|
|
module Graphics.Color (rgba,rgb,hsva,hsv,
|
|
|
|
complement,
|
|
|
|
red,lime,blue,
|
|
|
|
yellow,cyan,magenta,
|
|
|
|
maroon,navy,green,
|
|
|
|
teal,purple,
|
|
|
|
violet,forestGreen,
|
2013-03-10 09:40:31 +00:00
|
|
|
black,white,gray,grey,
|
|
|
|
linear,radial) where
|
2013-02-10 11:58:40 +00:00
|
|
|
|
2012-10-05 02:01:20 +00:00
|
|
|
data Color = Color Int Int Int Float
|
|
|
|
|
2013-03-24 12:45:56 +00:00
|
|
|
-- Create RGB colors with an alpha component for transparency. The alpha component is specified with numbers between 0 and 1.
|
2012-10-05 02:01:20 +00:00
|
|
|
rgba = Color
|
2013-03-24 12:45:56 +00:00
|
|
|
|
|
|
|
-- Create RGB colors from numbers between 0 and 255 inclusive.
|
2012-10-05 02:01:20 +00:00
|
|
|
rgb r g b = Color r g b 1
|
|
|
|
|
|
|
|
red = Color 255 0 0 1
|
2013-02-10 11:58:40 +00:00
|
|
|
lime = Color 0 255 0 1
|
2012-10-05 02:01:20 +00:00
|
|
|
blue = Color 0 0 255 1
|
2013-02-10 11:58:40 +00:00
|
|
|
|
2012-10-05 02:01:20 +00:00
|
|
|
yellow = Color 255 255 0 1
|
|
|
|
cyan = Color 0 255 255 1
|
|
|
|
magenta = Color 255 0 255 1
|
2013-02-10 11:58:40 +00:00
|
|
|
|
2012-10-05 02:01:20 +00:00
|
|
|
black = Color 0 0 0 1
|
|
|
|
white = Color 255 255 255 1
|
2013-02-10 11:58:40 +00:00
|
|
|
|
2012-10-05 02:01:20 +00:00
|
|
|
gray = Color 128 128 128 1
|
|
|
|
grey = Color 128 128 128 1
|
2013-02-10 11:58:40 +00:00
|
|
|
|
|
|
|
maroon = Color 128 0 0 1
|
|
|
|
navy = Color 0 0 128 1
|
|
|
|
green = Color 0 128 0 1
|
|
|
|
|
|
|
|
teal = Color 0 128 128 1
|
|
|
|
purple = Color 128 0 128 1
|
|
|
|
|
|
|
|
forestGreen = Color 34 139 34 1
|
|
|
|
violet = Color 238 130 238 1
|
|
|
|
|
2013-03-24 12:45:56 +00:00
|
|
|
-- Produce a “complementary color”. The two colors will accent each other.
|
2013-03-10 09:40:31 +00:00
|
|
|
complement : Color -> Color
|
2013-03-24 12:45:56 +00:00
|
|
|
|
|
|
|
-- Create HSV colors with an alpha component for transparency. The alpha component is specified with numbers between 0 and 1.
|
2013-03-10 09:40:31 +00:00
|
|
|
hsva : Int -> Float -> Float -> Float -> Color
|
2013-03-24 12:45:56 +00:00
|
|
|
|
|
|
|
-- Create HSV colors. HSV stands for hue-saturation-value.
|
|
|
|
--
|
|
|
|
-- Hue is a degree from 0 to 360 representing a color wheel: red at 0°, green at 120°, blue at 240°, and red again at 360°.
|
|
|
|
-- This makes it easy to cycle through colors and compute color complements, triads, tetrads, etc.
|
|
|
|
--
|
|
|
|
-- Saturation is a number between 1 and 0 where lowering this number makes your color more grey. This can help you tone a color down.
|
|
|
|
--
|
|
|
|
-- Value is also a number between 1 and 0. Lowering this number makes your color more black.
|
|
|
|
--
|
|
|
|
-- Look up the “HSV cylinder” for more information.
|
2013-03-10 09:40:31 +00:00
|
|
|
hsv : Int -> Float -> Float -> Color
|
2013-03-06 03:46:35 +00:00
|
|
|
|
|
|
|
data Gradient
|
|
|
|
= Linear [(Float,Color)] (Float,Float) (Float,Float)
|
|
|
|
| Radial [(Float,Color)] (Float,Float) Float (Float,Float) Float
|
|
|
|
|
2013-03-10 09:40:31 +00:00
|
|
|
linear = Linear
|
2013-03-14 08:04:51 +00:00
|
|
|
radial = Radial
|