noahzgordon / elm-color-extra / Color.Gradient

Gradient


type alias GradientStop =
( Basics.Float, Color )

A color and a stop value that indicates where the color appears in a gradient. The stop value must be between 0 and 1.


type alias Gradient =
List GradientStop


type alias Palette =
List Color

Create a new gradient Palette from a given Palette, with a given size.

linearGradient : Color.Interpolate.Space -> Palette -> Basics.Int -> Palette

Create a new Palette with gradient colors from a given Palette, with a given size.

p1 : Palette
p1 =
  [ rgb 200 0 200
  , rgb 0 100 100
  , rgb 100 0 0
  ]
gradient RGB p1 5 -- [RGBA 200 0 200 1,RGBA 100 50 150 1,RGBA 0 100 100 1,RGBA 50 50 50 1,RGBA 100 0 0 1]

linearGradientFromStops : Color.Interpolate.Space -> Gradient -> Basics.Int -> Palette

Create a new Palette with gradient colors from a given Gradient, with a given size.

g : Gradient
g =
  [ (0, rgb 200 0 200)
  , (0.25, rgb 0 100 100)
  , (1, rgb 150 175 160)
  ]
gradientFromStops RGB g 5 -- [RGBA 200 0 200 1,RGBA 0 100 100 1,RGBA 50 125 120 1,RGBA 100 150 140 1,RGBA 150 175 160 1]


type alias CosineGradientSetting =
( Basics.Float
, Basics.Float
, Basics.Float 
)

parameters for calculate RGB values for cosine gradients

cosineGradient : CosineGradientSetting -> CosineGradientSetting -> CosineGradientSetting -> CosineGradientSetting -> Basics.Int -> Palette

Create a gradient based on the on an idea by Iñigo Quílez For an interactive example have a look at Karsten Schmidt's example from his thi.ng library