y047aka / elm-hsl-color / HslaColor

This package defines a standard Hsla type.

Types


type HslaColor

Represents a color.

Creating color

From numbers

hsl : Basics.Float -> Basics.Float -> Basics.Float -> HslaColor

Creates a color from HSL (hue, saturation, lightness) values between 0.0 and 1.0 (inclusive).

See also:

If you need to provide an alpha value, see hsla.

If you want to be more explicit with parameter names, see fromHsla.

hsla : Basics.Float -> Basics.Float -> Basics.Float -> Basics.Float -> HslaColor

Creates a color from HSLA (hue, saturation, lightness, alpha) values between 0.0 and 1.0 (inclusive).

See also:

If you want to be more concise and want full alpha, see hsl.

If you want to be more explicit with parameter names, see fromHsla.

hsl360 : Basics.Float -> Basics.Float -> Basics.Float -> HslaColor

Creates a color from HSL (hue, saturation, lightness) float values between:

See also:

If you want to provide Hsl values as Float values between 0.0 and 1.0, see hsl.

rgb255 : Basics.Int -> Basics.Int -> Basics.Int -> HslaColor

Creates a color from RGB (red, green, blue) integer values between 0 and 255.

This is a convenience function if you find passing RGB channels as integers scaled to 255 more intuitive.

See also:

If you want to provide RGB values as Float values between 0.0 and 1.0, see rgb.

rgb : Basics.Float -> Basics.Float -> Basics.Float -> HslaColor

Creates a color from RGB (red, green, blue) values between 0.0 and 1.0 (inclusive).

This is a convenience function for making a color value with full opacity.

See also:

If you want to pass RGB values as Int values between 0 and 255, see rgb255.

If you need to provide an alpha value, see rgba.

If you want to be more explicit with parameter names, see fromRgba.

rgba : Basics.Float -> Basics.Float -> Basics.Float -> Basics.Float -> HslaColor

Creates a color from RGBA (red, green, blue, alpha) values between 0.0 and 1.0 (inclusive).

See also:

If you want to be more concise and want full alpha, see rgb.

If you want to be more explicit with parameter names, see fromRgba.

From records

fromRgba : { red : Basics.Float, green : Basics.Float, blue : Basics.Float, alpha : Basics.Float } -> HslaColor

Creates from a record of RGBA values (red, green, blue, alpha) between 0.0 and 1.0 (inclusive).

See also:

If you want to be more concise, see rgba or rgb.

fromHsla : { hue : Basics.Float, saturation : Basics.Float, lightness : Basics.Float, alpha : Basics.Float } -> HslaColor

Creates a color from HSLA (hue, saturation, lightness, alpha) values between:

See also:

If you want to be more concise, see hsla or hsl.

Using colors with HTML/CSS/SVG

toCssString : HslaColor -> String

Converts a Hsla type to a string suitable for use in CSS. The string will conform to CSS Color Module Level 3.

Html.Attributes.style "background-color" (Hsl.toCssString Hsl.lightPurple)

Extracing values from Hsla type

toRgba : HslaColor -> { red : Basics.Float, green : Basics.Float, blue : Basics.Float, alpha : Basics.Float }

Extract the RGBA (red, green, blue, alpha) components Hsla type. The component values will be between 0.0 and 1.0 (inclusive).

toHsla : HslaColor -> { hue : Basics.Float, saturation : Basics.Float, lightness : Basics.Float, alpha : Basics.Float }

Extract the HSLA (hue, saturation, lightness, alpha) components from a Hsla type. The component values will be between 0.0 and 1.0 (inclusive).

toColor : HslaColor -> Color

Convert an HslaColor to a Color

Seed colors

red : HslaColor

yellow : HslaColor

lime : HslaColor

cyan : HslaColor

blue : HslaColor

magenta : HslaColor

white, gray, black

white : HslaColor

gray : HslaColor

black : HslaColor