helm-1.0.0: A functionally reactive game engine.

Safe HaskellSafe
LanguageHaskell2010

Helm.Color

Contents

Description

Contains all data structures and functions for composing colors.

Synopsis

Types

data Color Source

Represents a color. It is represented interally as an RGBA color, but the utility functions hsva, hsv, etc. can be used to convert from other popular formats to this structure.

Constructors

Color !Double !Double !Double !Double 

data Gradient Source

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.

Constructors

Linear !(Double, Double) !(Double, Double) ![(Double, Color)]

A linear gradient.

Radial !(Double, Double) !Double !(Double, Double) !Double ![(Double, Color)]

A radial gradient.

Composing

rgba :: Double -> Double -> Double -> Double -> Color Source

Create an RGBA color.

rgb :: Double -> Double -> Double -> Color Source

Create an RGB color.

hsva :: Double -> Double -> Double -> Double -> Color Source

Create an RGBA color from HSVA values.

hsv :: Double -> Double -> Double -> Color Source

Create an RGB color from HSV values.

blend :: [Color] -> Color Source

Blends colors together by averaging out their color components.

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.

radial :: (Double, Double) -> Double -> (Double, Double) -> Double -> [(Double, Color)] -> Gradient Source

Creates a radial gradient. Takes a starting position and radius, ending position and radius and a list of color stops. See the document for linear for more information on color stops.