3{-| Library for working with colors. Includes
4[RGB](https://en.wikipedia.org/wiki/RGB_color_model) and
5[HSV](http://en.wikipedia.org/wiki/HSL_and_HSV) creation, gradients, and
9@docs rgb, rgba, hsv, hsva, greyscale, grayscale
18These colors come from the [Tango
19palette](http://tango.freedesktop.org/Tango_Icon_Theme_Guidelines)
20which provides aesthetically reasonable defaults for colors. Each color also
21comes with a light and dark version.
24@docs red, orange, yellow, green, blue, purple, brown
27@docs lightRed, lightOrange, lightYellow, lightGreen, lightBlue, lightPurple,
31@docs darkRed, darkOrange, darkYellow, darkGreen, darkBlue, darkPurple,
34### Eight Shades of Grey
35These colors are a compatible series of shades of grey, fitting nicely
36with the Tango palette.
37@docs white, lightGrey, grey, darkGrey, lightCharcoal, charcoal, darkCharcoal, black
39These are identical to the *grey* versions. It seems the spelling is regional, but
40that has never helped me remember which one I should be writing.
41@docs lightGray, gray, darkGray
48data Color = Color Int Int Int Float
50{-| Create RGB colors with an alpha component for transparency.
51The alpha component is specified with numbers between 0 and 1. -}
52rgba : Int -> Int -> Int -> Float -> Color
55{-| Create RGB colors from numbers between 0 and 255 inclusive. -}
56rgb : Int -> Int -> Int -> Color
57rgb r g b = Color r g b 1
60lightRed = Color 239 41 41 1
64darkRed = Color 164 0 0 1
67lightOrange = Color 252 175 62 1
69orange = Color 245 121 0 1
71darkOrange = Color 206 92 0 1
74lightYellow = Color 255 233 79 1
76yellow = Color 237 212 0 1
78darkYellow = Color 196 160 0 1
81lightGreen = Color 138 226 52 1
83green = Color 115 210 22 1
85darkGreen = Color 78 154 6 1
88lightBlue = Color 114 159 207 1
90blue = Color 52 101 164 1
92darkBlue = Color 32 74 135 1
95lightPurple = Color 173 127 168 1
97purple = Color 117 80 123 1
99darkPurple = Color 92 53 102 1
102lightBrown = Color 233 185 110 1
104brown = Color 193 125 17 1
106darkBrown = Color 143 89 2 1
111white = Color 255 255 255 1
114lightGrey = Color 238 238 236 1
116grey = Color 211 215 207 1
118darkGrey = Color 186 189 182 1
121lightGray = Color 238 238 236 1
123gray = Color 211 215 207 1
125darkGray = Color 186 189 182 1
128lightCharcoal = Color 136 138 133 1
130charcoal = Color 85 87 83 1
132darkCharcoal = Color 46 52 54 1
134{-| Produce a gray based on the input. 0 is white, 1 is black. -}
135grayscale : Float -> Color
136grayscale p = hsv 0 0 (1-p)
138greyscale : Float -> Color
139greyscale p = hsv 0 0 (1-p)
141{-| Produce a “complementary color”.
142The two colors will accent each other. -}
143complement : Color -> Color
144complement = Native.Color.complement
146{-| Create [HSV colors](http://en.wikipedia.org/wiki/HSL_and_HSV)
147with an alpha component for transparency. -}
148hsva : Float -> Float -> Float -> Float -> Color
149hsva = Native.Color.hsva
151{-| Create [HSV colors](http://en.wikipedia.org/wiki/HSL_and_HSV). This is very
152convenient for creating colors that cycle and shift. Hue is an angle and should
153be given in standard Elm angles (radians). -}
154hsv : Float -> Float -> Float -> Color
155hsv = Native.Color.hsv
158 = Linear (Float,Float) (Float,Float) [(Float,Color)]
159 | Radial (Float,Float) Float (Float,Float) Float [(Float,Color)]
161{-| Create a linear gradient. Takes a start and end point and then a series of
162“color stops” that indicate how to interpolate between the start and
163end points. See [this example](/edit/examples/Elements/LinearGradient.elm) for a
164more visual explanation. -}
165linear : (number, number) -> (number, number) -> [(Float,Color)] -> Gradient
168{-| Create a radial gradient. First takes a start point and inner radius. Then
169takes an end point and outer radius. It then takes a series of “color
170stops” that indicate how to interpolate between the inner and outer
171circles. See [this example](/edit/examples/Elements/RadialGradient.elm) for a
172more visual explanation. -}
173radial : (number,number) -> number -> (number,number) -> number -> [(Float,Color)] -> Gradient
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list