on c2fc03c help sign in
95 lines 2.8 kB history raw
2module Graphics.Color (rgba,rgb,hsva,hsv,
3 complement,
4 red,lime,blue,
5 yellow,cyan,magenta,
6 maroon,navy,green,
7 teal,purple,
8 violet,forestGreen,
9 black,white,gray,grey,
10 linear,radial) where
12data Color = Color Int Int Int Float
14-- Create RGB colors with an alpha component for transparency. The alpha component is specified with numbers between 0 and 1.
15rgba : Int -> Int -> Int -> Float -> Color
16rgba = Color
18-- Create RGB colors from numbers between 0 and 255 inclusive.
19rgb : Int -> Int -> Int -> Color
20rgb r g b = Color r g b 1
22red : Color
23red = Color 255 0 0 1
24lime : Color
25lime = Color 0 255 0 1
26blue : Color
27blue = Color 0 0 255 1
29yellow : Color
30yellow = Color 255 255 0 1
31cyan : Color
32cyan = Color 0 255 255 1
33magenta : Color
34magenta = Color 255 0 255 1
36black : Color
37black = Color 0 0 0 1
38white : Color
39white = Color 255 255 255 1
41gray : Color
42gray = Color 128 128 128 1
43grey : Color
44grey = Color 128 128 128 1
46maroon : Color
47maroon = Color 128 0 0 1
48navy : Color
49navy = Color 0 0 128 1
50green : Color
51green = Color 0 128 0 1
53teal : Color
54teal = Color 0 128 128 1
55purple : Color
56purple = Color 128 0 128 1
58violet : Color
59violet = Color 238 130 238 1
60forestGreen : Color
61forestGreen = Color 34 139 34 1
63-- Produce a “complementary color”.
64-- The two colors will accent each other.
65complement : Color -> Color
67-- Create HSV colors with an alpha component for transparency.
68-- The alpha component is specified with numbers between 0 and 1.
69hsva : Int -> Float -> Float -> Float -> Color
71-- Create HSV colors. HSV stands for hue-saturation-value.
72--
73-- Hue is a degree from 0 to 360 representing a color wheel: red at 0°,
74-- green at 120°, blue at 240°, and red again at 360°.
75-- This makes it easy to cycle through colors and compute color complements,
76-- triads, tetrads, etc.
77--
78-- Saturation is a number between 1 and 0 where lowering this number makes
79-- your color more grey. This can help you tone a color down.
80--
81-- Value is also a number between 1 and 0. Lowering this number makes your
82-- color more black.
83--
84-- Look up the “HSV cylinder” for more information.
85hsv : Int -> Float -> Float -> Color
87data Gradient
88 = Linear (Float,Float) (Float,Float) [(Float,Color)]
89 | Radial (Float,Float) Float (Float,Float) Float [(Float,Color)]
91linear : (Number,Number) -> (Number,Number) -> [(Float,Color)] -> Gradient
92linear = Linear
93radial : (Number,Number) -> Number ->
94 (Number,Number) -> Number -> [(Float,Color)] -> Gradient
95radial = Radial