the-sett / elm-color / Color

This module provides a simple way of describing colors as RGB with alpha transparency, based on this simple data structure:

type alias Color =
    { red : Int, green : Int, blue : Int, alpha : Float }

The intention here is to provide a minimal and convenient representation of color for rendering purposes.

The color representations:


type alias Color =
{ red : Basics.Int
, green : Basics.Int
, blue : Basics.Int
, alpha : Basics.Float 
}

A description of a color as computers see them.

Constructors:

rgb : Basics.Int -> Basics.Int -> Basics.Int -> Color

Builds an RGBA color from its RGB components at 100% opacity.

rgba : Basics.Int -> Basics.Int -> Basics.Int -> Basics.Float -> Color

Builds an RGBA color from all of its components.

hsl : Basics.Float -> Basics.Float -> Basics.Float -> Color

Builds and RGBA color from its hue, saturation and lighness (HSL) representation at 100% opacity.

hsla : Basics.Float -> Basics.Float -> Basics.Float -> Basics.Float -> Color

Builds and RGBA color from its hue, saturation, lighness and alpha (HSLA) representation.

grayscale : Basics.Float -> Color

Makes a grey level from 0 to 1.

greyscale : Basics.Float -> Color

Makes a grey level from 0 to 1.

complement : Color -> Color

Forms the complement of a color.

Color space conversion/extraction:

toRgb : Color -> { red : Basics.Int, green : Basics.Int, blue : Basics.Int, alpha : Basics.Float }

Converts the RGBA color to its RGBA representation - that is, does nothing.

toHsl : Color -> { hue : Basics.Float, saturation : Basics.Float, lightness : Basics.Float, alpha : Basics.Float }

Converts the RGBA color to its HSLA representation.

Some basic colors to get you started:

black : Color

blue : Color

brown : Color

charcoal : Color

darkBlue : Color

darkBrown : Color

darkCharcoal : Color

darkGray : Color

darkGreen : Color

darkGrey : Color

darkOrange : Color

darkPurple : Color

darkRed : Color

darkYellow : Color

gray : Color

green : Color

grey : Color

lightBlue : Color

lightBrown : Color

lightCharcoal : Color

lightGray : Color

lightGreen : Color

lightGrey : Color

lightOrange : Color

lightPurple : Color

lightRed : Color

lightYellow : Color

orange : Color

purple : Color

red : Color

white : Color

yellow : Color