Orasund / elm-svg-writer / Svg.Path

Building Paths


type Path
    = JumpTo (( Basics.Float, Basics.Float )) Path
    | LineTo (( Basics.Float, Basics.Float )) Path
    | ArcTo (( Basics.Float, Basics.Float )) ({ radiusX : Basics.Float, radiusY : Basics.Float, rotation : Basics.Float, takeTheLongWay : Basics.Bool, clockwise : Basics.Bool }) Path
    | Custom String Path
    | EndClosed
    | End

Commands for writing Paths.

You might want to use PathBuilder to build paths.

startAt : ( Basics.Float, Basics.Float ) -> PathBuilder

start building a path

end : PathBuilder -> Path

end the path

endClosed : PathBuilder -> Path

move back to the start and end the path

drawLineBy : ( Basics.Float, Basics.Float ) -> PathBuilder -> PathBuilder

draw a line to a relative point

drawLineTo : ( Basics.Float, Basics.Float ) -> PathBuilder -> PathBuilder

draw a line to a point

drawCircleArcAround : ( Basics.Float, Basics.Float ) -> { angle : Basics.Float, clockwise : Basics.Bool } -> PathBuilder -> PathBuilder

Draw a circle arc around a center point

drawCircleArcAroundBy : ( Basics.Float, Basics.Float ) -> { angle : Basics.Float, clockwise : Basics.Bool } -> PathBuilder -> PathBuilder

draw a circle arc around a relative center

jumpBy : ( Basics.Float, Basics.Float ) -> PathBuilder -> PathBuilder

jump by a relative amount (without drawing)

jumpTo : ( Basics.Float, Basics.Float ) -> PathBuilder -> PathBuilder

jump to a point (without drawing)

Advanced

drawArcBy : ( Basics.Float, Basics.Float ) -> { radiusX : Basics.Float, radiusY : Basics.Float, rotation : Basics.Float, takeTheLongWay : Basics.Bool, clockwise : Basics.Bool } -> PathBuilder -> PathBuilder

draw an arc to a relative point

drawArcTo : ( Basics.Float, Basics.Float ) -> { radiusX : Basics.Float, radiusY : Basics.Float, rotation : Basics.Float, takeTheLongWay : Basics.Bool, clockwise : Basics.Bool } -> PathBuilder -> PathBuilder

draw an arc to a point

drawCircleArcBy : ( Basics.Float, Basics.Float ) -> { angle : Basics.Float, takeTheLongWay : Basics.Bool, clockwise : Basics.Bool } -> PathBuilder -> PathBuilder

draw a circle arc to a relative point

drawCircleArcTo : ( Basics.Float, Basics.Float ) -> { angle : Basics.Float, takeTheLongWay : Basics.Bool, clockwise : Basics.Bool } -> PathBuilder -> PathBuilder

draw a circle arc to a point

custom : (( Basics.Float, Basics.Float ) -> ( ( Basics.Float, Basics.Float ), String )) -> PathBuilder -> PathBuilder

custom path command.

You should only use this if you know what your doing.

```
startAt (50,50)
|> custom (\(x,y) -> ((x+10,y+10),"l10 10"))
|> end
```

toString : Path -> String

Convert the path to a string.

You can use it with elm/svg like this:

    Svg.path
        [ Svg.Attributes.d (toString path)]
        []


type alias PathBuilder =
( ( Basics.Float
, Basics.Float )
, Path -> Path 
)

Builds Paths.

Start building paths with startAt and end it with end.