Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Contains all data structures and functions for composing colors.
- data Color = Color !Double !Double !Double !Double
- data Gradient
- rgba :: Double -> Double -> Double -> Double -> Color
- rgb :: Double -> Double -> Double -> Color
- hsva :: Double -> Double -> Double -> Double -> Color
- hsv :: Double -> Double -> Double -> Color
- blend :: [Color] -> Color
- complement :: Color -> Color
- linear :: (Double, Double) -> (Double, Double) -> [(Double, Color)] -> Gradient
- radial :: (Double, Double) -> Double -> (Double, Double) -> Double -> [(Double, Color)] -> Gradient
Types
Represents a gradient.
Helm supports radial and linear gradients. Radial gradients are based on a set of colors transitioned over certain radii in an arc pattern. Linear gradients are a set of colors transitioned in a straight line.
Composing
complement :: Color -> Color Source
Calculate the complementary color for a color provided color. This is useful for outlining a filled shape in a color clearly distinguishable from the fill color.
linear :: (Double, Double) -> (Double, Double) -> [(Double, Color)] -> Gradient Source
Creates a linear gradient. Takes a starting position, ending position and a list of color stops (which are colors combined with a floating value between 0.0 and 1.0 that describes at what step along the line between the starting position and ending position the paired color should be transitioned to).
linear (0, 0) (100, 100) [(0, black), (1, white)]
The above example creates a gradient that starts at (0, 0) and ends at (100, 100). In other words, it's a diagonal gradient, transitioning from the top-left to the bottom-right. The provided color stops result in the gradient transitioning from black to white.