on b930ac2 help sign in
67 lines 2.3 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 = Color
17-- Create RGB colors from numbers between 0 and 255 inclusive.
18rgb r g b = Color r g b 1
20red = Color 255 0 0 1
21lime = Color 0 255 0 1
22blue = Color 0 0 255 1
24yellow = Color 255 255 0 1
25cyan = Color 0 255 255 1
26magenta = Color 255 0 255 1
28black = Color 0 0 0 1
29white = Color 255 255 255 1
31gray = Color 128 128 128 1
32grey = Color 128 128 128 1
34maroon = Color 128 0 0 1
35navy = Color 0 0 128 1
36green = Color 0 128 0 1
38teal = Color 0 128 128 1
39purple = Color 128 0 128 1
41forestGreen = Color 34 139 34 1
42violet = Color 238 130 238 1
44-- Produce a “complementary color”. The two colors will accent each other.
45complement : Color -> Color
47-- Create HSV colors with an alpha component for transparency. The alpha component is specified with numbers between 0 and 1.
48hsva : Int -> Float -> Float -> Float -> Color
50-- Create HSV colors. HSV stands for hue-saturation-value.
51--
52-- 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°.
53-- This makes it easy to cycle through colors and compute color complements, triads, tetrads, etc.
54--
55-- 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.
56--
57-- Value is also a number between 1 and 0. Lowering this number makes your color more black.
58--
59-- Look up the “HSV cylinder” for more information.
60hsv : Int -> Float -> Float -> Color
62data Gradient
63 = Linear [(Float,Color)] (Float,Float) (Float,Float)
64 | Radial [(Float,Color)] (Float,Float) Float (Float,Float) Float
66linear = Linear
67radial = Radial