on fbad8ea help sign in
elk/libraries/Color.elm
88 lines 2.8 kB history raw
2module Color where
4import Native.Color
6data Color = Color Int Int Int Float
8-- Create RGB colors with an alpha component for transparency.
9-- The alpha component is specified with numbers between 0 and 1.
10rgba : Int -> Int -> Int -> Float -> Color
11rgba = Color
13-- Create RGB colors from numbers between 0 and 255 inclusive.
14rgb : Int -> Int -> Int -> Color
15rgb r g b = Color r g b 1
17lightYellow = Color 255 233 79 1
18yellow = Color 237 212 0 1
19darkYellow = Color 196 160 0 1
21lightOrange = Color 252 175 62 1
22orange = Color 245 121 0 1
23darkOrange = Color 206 92 0 1
25lightBrown = Color 233 185 110 1
26brown = Color 193 125 17 1
27darkBrown = Color 143 89 2 1
29lightGreen = Color 138 226 52 1
30green = Color 115 210 22 1
31darkGreen = Color 78 154 6 1
33lightBlue = Color 114 159 207 1
34blue = Color 52 101 164 1
35darkBlue = Color 32 74 135 1
37lightPurple = Color 173 127 168 1
38purple = Color 117 80 123 1
39darkPurple = Color 92 53 102 1
41lightRed = Color 239 41 41 1
42red = Color 204 0 0 1
43darkRed = Color 164 0 0 1
45black = Color 0 0 0 1
46white = Color 255 255 255 1
48gray : Color
49gray = Color 128 128 128 1
50grey : Color
51grey = Color 128 128 128 1
53-- Produce a “complementary color”.
54-- The two colors will accent each other.
55complement : Color -> Color
56complement = Native.Color.complement
58-- Create [HSV colors](http://en.wikipedia.org/wiki/HSL_and_HSV)
59-- with an alpha component for transparency.
60hsva : Float -> Float -> Float -> Float -> Color
61hsva = Native.Color.hsva
63-- Create [HSV colors](http://en.wikipedia.org/wiki/HSL_and_HSV).
64-- This is very convenient for creating colors that cycle and shift.
65-- Hue is an angle and should be given in standard Elm angles (radians).
66--
67-- hsv (degrees 240) 1 1 == blue
68hsv : Float -> Float -> Float -> Color
69hsv = Native.Color.hsv
71data Gradient
72 = Linear (Float,Float) (Float,Float) [(Float,Color)]
73 | Radial (Float,Float) Float (Float,Float) Float [(Float,Color)]
75-- Create a linear gradient. Takes a start and end point and then a series
76-- of “color stops” that indicate how to interpolate between
77-- the start and end points. See [this example](/edit/examples/Elements/LinearGradient.elm) for
78-- a more visual explanation.
79linear : (number, number) -> (number, number) -> [(Float,Color)] -> Gradient
80linear = Linear
82-- Create a radial gradient. First takes a start point and inner radius.
83-- Then takes an end point and outer radius. It then takes a series
84-- of “color stops” that indicate how to interpolate between
85-- the inner and outer circles. See [this example](/edit/examples/Elements/RadialGradient.elm) for
86-- a more visual explanation.
87radial : (number,number) -> number -> (number,number) -> number -> [(Float,Color)] -> Gradient
88radial = Radial