This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.

Diagrams.FillStroke

Construct fills and strokes for diagrams.

Types

type alias FillStroke = { fill : Maybe FillStyle , stroke : Maybe C.LineStyle }
type FillStyle = Solid Color.Color | Texture String | Grad Color.Gradient

literally a copy of Graphics.Collage.FillStyle, cuz it's no longer exported

Constructors

justFill : FillStyle -> FillStroke
justStroke : C.LineStyle -> FillStroke
fillAndStroke : FillStyle -> C.LineStyle -> FillStroke
invisible : FillStroke
justSolidFill : Color.Color -> FillStroke
withAlpha : Float -> Color.Color -> Color.Color
defaultStroke : C.LineStyle
halfStrokeWidth : FillStroke -> Float
module Diagrams.FillStroke where

{-| Construct fills and strokes for diagrams.

# Types
@docs FillStroke, FillStyle

# Constructors
@docs justFill, justStroke, fillAndStroke, invisible, justSolidFill, withAlpha, defaultStroke, halfStrokeWidth
-}

import Color
import Graphics.Collage as C

{-| literally a copy of Graphics.Collage.FillStyle, cuz it's no longer exported -}
type FillStyle
    = Solid Color.Color
    | Texture String
    | Grad Color.Gradient

{-|-}
type alias FillStroke =
    { fill : Maybe FillStyle
    , stroke : Maybe C.LineStyle
    }

{-|-}
justFill : FillStyle -> FillStroke
justFill fs =
  { fill = Just fs, stroke = Nothing }

{-|-}
justStroke : C.LineStyle -> FillStroke
justStroke ls =
  { fill = Nothing, stroke = Just ls }

{-|-}
fillAndStroke : FillStyle -> C.LineStyle -> FillStroke
fillAndStroke fs ls =
  { fill = Just fs, stroke = Just ls }

{-|-}
invisible : FillStroke
invisible =
  { fill = Nothing, stroke = Nothing }

{-|-}
defaultStroke : C.LineStyle
defaultStroke =
  let defLine = C.defaultLine
  in { defLine | width = 3
               , cap = C.Padded }

{-|-}
justSolidFill : Color.Color -> FillStroke
justSolidFill color =
  justFill <| Solid color

{-|-}
halfStrokeWidth : FillStroke -> Float
halfStrokeWidth fs =
  case fs.stroke of
    Just ls -> ls.width/2
    Nothing -> 0

{-|-}
withAlpha : Float -> Color.Color -> Color.Color
withAlpha newAlpha color =
  let {red, green, blue, alpha} = Color.toRgb color
  in Color.rgba red green blue newAlpha