on da346ea help sign in
elk/libraries/Color.elm
92 lines 2.7 kB history raw
2module Color where
4import Native.Color as Native
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
17red : Color
18red = Color 255 0 0 1
19lime : Color
20lime = Color 0 255 0 1
21blue : Color
22blue = Color 0 0 255 1
24yellow : Color
25yellow = Color 255 255 0 1
26cyan : Color
27cyan = Color 0 255 255 1
28magenta : Color
29magenta = Color 255 0 255 1
31black : Color
32black = Color 0 0 0 1
33white : Color
34white = Color 255 255 255 1
36gray : Color
37gray = Color 128 128 128 1
38grey : Color
39grey = Color 128 128 128 1
41maroon : Color
42maroon = Color 128 0 0 1
43navy : Color
44navy = Color 0 0 128 1
45green : Color
46green = Color 0 128 0 1
48teal : Color
49teal = Color 0 128 128 1
50purple : Color
51purple = Color 128 0 128 1
53violet : Color
54violet = Color 238 130 238 1
55forestGreen : Color
56forestGreen = Color 34 139 34 1
58-- Produce a “complementary color”.
59-- The two colors will accent each other.
60complement : Color -> Color
61complement = Native.complement
63-- Create [HSV colors](http://en.wikipedia.org/wiki/HSL_and_HSV)
64-- with an alpha component for transparency.
65hsva : Float -> Float -> Float -> Float -> Color
66hsva = Native.hsva
68-- Create [HSV colors](http://en.wikipedia.org/wiki/HSL_and_HSV).
69-- This is very convenient for creating colors that cycle and shift.
70--
71-- hsv (degrees 240) 1 1 == blue
72hsv : Float -> Float -> Float -> Color
73hsv = Native.hsv
75data Gradient
76 = Linear (Float,Float) (Float,Float) [(Float,Color)]
77 | Radial (Float,Float) Float (Float,Float) Float [(Float,Color)]
79-- Create a linear gradient. Takes a start and end point and then a series
80-- of “color stops” that indicate how to interpolate between
81-- the start and end points. See [this example](/edit/examples/Elements/LinearGradient.elm) for
82-- a more visual explanation.
83linear : (number, number) -> (number, number) -> [(Float,Color)] -> Gradient
84linear = Linear
86-- Create a radial gradient. First takes a start point and inner radius.
87-- Then takes an end point and outer radius. It then takes a series
88-- of “color stops” that indicate how to interpolate between
89-- the inner and outer circles. See [this example](/edit/examples/Elements/RadialGradient.elm) for
90-- a more visual explanation.
91radial : (number,number) -> number -> (number,number) -> number -> [(Float,Color)] -> Gradient
92radial = Radial