on ac67dbd help sign in
97 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.
15-- The alpha component is specified with numbers between 0 and 1.
16rgba : Int -> Int -> Int -> Float -> Color
17rgba = Color
19-- Create RGB colors from numbers between 0 and 255 inclusive.
20rgb : Int -> Int -> Int -> Color
21rgb r g b = Color r g b 1
23red : Color
24red = Color 255 0 0 1
25lime : Color
26lime = Color 0 255 0 1
27blue : Color
28blue = Color 0 0 255 1
30yellow : Color
31yellow = Color 255 255 0 1
32cyan : Color
33cyan = Color 0 255 255 1
34magenta : Color
35magenta = Color 255 0 255 1
37black : Color
38black = Color 0 0 0 1
39white : Color
40white = Color 255 255 255 1
42gray : Color
43gray = Color 128 128 128 1
44grey : Color
45grey = Color 128 128 128 1
47maroon : Color
48maroon = Color 128 0 0 1
49navy : Color
50navy = Color 0 0 128 1
51green : Color
52green = Color 0 128 0 1
54teal : Color
55teal = Color 0 128 128 1
56purple : Color
57purple = Color 128 0 128 1
59violet : Color
60violet = Color 238 130 238 1
61forestGreen : Color
62forestGreen = Color 34 139 34 1
64-- Produce a “complementary color”.
65-- The two colors will accent each other.
66complement : Color -> Color
68-- Create HSV colors with an alpha component for transparency.
69-- The alpha component is specified with numbers between 0 and 1.
70hsva : Int -> Float -> Float -> Float -> Color
72-- Create HSV colors. HSV stands for hue-saturation-value.
73--
74-- Hue is a degree from 0 to 360 representing a color wheel: red at 0°,
75-- green at 120°, blue at 240°, and red again at 360°.
76-- This makes it easy to cycle through colors and compute color complements,
77-- triads, tetrads, etc.
78--
79-- Saturation is a number between 1 and 0 where lowering this number makes
80-- your color more grey. This can help you tone a color down.
81--
82-- Value is also a number between 1 and 0. Lowering this number makes your
83-- color more black.
84--
85-- Look up the “HSV cylinder” for more information.
86hsv : Int -> Float -> Float -> Color
88data Gradient
89 = Linear (Float,Float) (Float,Float) [(Float,Color)]
90 | Radial (Float,Float) Float (Float,Float) Float [(Float,Color)]
92linear : (Number a, Number a) ->
93 (Number a, Number a) -> [(Float,Color)] -> Gradient
94linear = Linear
95radial : (Number a,Number a) -> Number a ->
96 (Number a,Number a) -> Number a -> [(Float,Color)] -> Gradient
97radial = Radial