on eaa751d help sign in
elk/libraries/Color.elm
87 lines 2.6 kB history raw
2module Color where
4data Color = Color Int Int Int Float
6-- Create RGB colors with an alpha component for transparency.
7-- The alpha component is specified with numbers between 0 and 1.
8rgba : Int -> Int -> Int -> Float -> Color
9rgba = Color
11-- Create RGB colors from numbers between 0 and 255 inclusive.
12rgb : Int -> Int -> Int -> Color
13rgb r g b = Color r g b 1
15red : Color
16red = Color 255 0 0 1
17lime : Color
18lime = Color 0 255 0 1
19blue : Color
20blue = Color 0 0 255 1
22yellow : Color
23yellow = Color 255 255 0 1
24cyan : Color
25cyan = Color 0 255 255 1
26magenta : Color
27magenta = Color 255 0 255 1
29black : Color
30black = Color 0 0 0 1
31white : Color
32white = Color 255 255 255 1
34gray : Color
35gray = Color 128 128 128 1
36grey : Color
37grey = Color 128 128 128 1
39maroon : Color
40maroon = Color 128 0 0 1
41navy : Color
42navy = Color 0 0 128 1
43green : Color
44green = Color 0 128 0 1
46teal : Color
47teal = Color 0 128 128 1
48purple : Color
49purple = Color 128 0 128 1
51violet : Color
52violet = Color 238 130 238 1
53forestGreen : Color
54forestGreen = Color 34 139 34 1
56-- Produce a “complementary color”.
57-- The two colors will accent each other.
58complement : Color -> Color
60-- Create [HSV colors](http://en.wikipedia.org/wiki/HSL_and_HSV)
61-- with an alpha component for transparency.
62hsva : Float -> Float -> Float -> Float -> Color
64-- Create [HSV colors](http://en.wikipedia.org/wiki/HSL_and_HSV).
65-- This is very convenient for creating colors that cycle and shift.
66--
67-- hsv (degrees 240) 1 1 == blue
68hsv : Float -> Float -> Float -> Color
70data Gradient
71 = Linear (Float,Float) (Float,Float) [(Float,Color)]
72 | Radial (Float,Float) Float (Float,Float) Float [(Float,Color)]
74-- Create a linear gradient. Takes a start and end point and then a series
75-- of “color stops” that indicate how to interpolate between
76-- the start and end points. See [this example](/edit/examples/Elements/LinearGradient.elm) for
77-- a more visual explanation.
78linear : (Number a, Number a) -> (Number a, Number a) -> [(Float,Color)] -> Gradient
79linear = Linear
81-- Create a radial gradient. First takes a start point and inner radius.
82-- Then takes an end point and outer radius. It then takes a series
83-- of “color stops” that indicate how to interpolate between
84-- the inner and outer circles. See [this example](/edit/examples/Elements/RadialGradient.elm) for
85-- a more visual explanation.
86radial : (Number a,Number a) -> Number a -> (Number a,Number a) -> Number a -> [(Float,Color)] -> Gradient
87radial = Radial