Skip to content

Commit

Permalink
small doc phrasing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertdev committed Nov 7, 2017
1 parent 1687e90 commit 66bf1a2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# One True Path

A general-purpose library for working with paths.
A general-purpose library for working with curves and paths.

The primary aim at the moment is SVG paths, but the types and functions in this package can also be
The primary aim is SVG paths, but the types and functions in this package can also be
used for animations or other graphics backends (webgl, canvas).

Additionally, this package is meant to serve as an interchange format between packages.

## Core Concepts

* **Path:** A list of subpaths
Expand Down Expand Up @@ -105,8 +107,7 @@ Path.parse pathAsString

The `Segment` module breaks down a line into four basic segment types, and exposes some mathematical functions (and the constructors, if you want to define your own fancy stuff).

The `LowLevel` module has that name for a reason. Unless you are making your own primitives, there is probably a better way.
If there isn't but you think there should be, please open an issue.
The `LowLevel.Command` module contains individual instructions. These should only be used for building other primitives! Making and combining curves should happen on the SubPath level.

## What about styling

Expand Down
42 changes: 23 additions & 19 deletions src/LowLevel/Command.elm
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ module LowLevel.Command
, merge
)

{-| Low-level access to absolute svg drawing commands.
{-| Low-level access to drawing instructions.
As the name implies, this is a low-level module that you probably shouldn't deal with.
This is a low-level module that you probably shouldn't deal with.
These instructions are meant to build up primitives (like in the `Curve` module); building of
curves should happen at the `SubPath` level.
## Threading State
Expand Down Expand Up @@ -121,10 +123,12 @@ type DrawTo
{ start = ( 0, 42 )
, end = ( 42, 0 )
, radii = ( 1, 1 )
, xAxisRotate = 0
, xAxisRotate = 90
, arcFlag = largestArc
, direction = clockwise
}
The xAxisRotate parameter is in degrees (note that in the `Segment` module, it is in radians).
-}
type alias EllipticalArcArgument =
{ radii : ( Float, Float )
Expand Down Expand Up @@ -351,15 +355,15 @@ fromLowLevelDrawTo drawto ({ start, cursor } as state) =
LowLevel.SmoothCurveTo mode coordinates ->
-- (If there is no previous command or if the previous command was not an C, c, S or s,
-- assume the first control point is coincident with the current point.)
coordinates
|> coordinatesToAbsolute mode (Vec2.map (Vec2.add cursor))
|> Maybe.map (makeControlPointExplicitVec2 state << Tuple.second)
|> Maybe.map
(\( finalState, finalPoints ) ->
( CurveTo finalPoints
, finalState
)
let
updateState ( finalState, finalPoints ) =
( CurveTo finalPoints
, finalState
)
in
coordinates
|> coordinatesToAbsolute mode (Vec2.map (Vec2.add cursor))
|> Maybe.map (updateState << makeControlPointExplicitVec2 state << Tuple.second)

LowLevel.QuadraticBezierCurveTo mode coordinates ->
let
Expand All @@ -373,15 +377,15 @@ fromLowLevelDrawTo drawto ({ start, cursor } as state) =
|> Maybe.map updateState

LowLevel.SmoothQuadraticBezierCurveTo mode coordinates ->
coordinates
|> coordinatesToAbsolute mode (Vec2.add cursor)
|> Maybe.map (makeControlPointExplicitVec1 state << Tuple.second)
|> Maybe.map
(\( finalState, finalPoints ) ->
( QuadraticBezierCurveTo finalPoints
, finalState
)
let
updateState ( finalState, finalPoints ) =
( QuadraticBezierCurveTo finalPoints
, finalState
)
in
coordinates
|> coordinatesToAbsolute mode (Vec2.add cursor)
|> Maybe.map (updateState << makeControlPointExplicitVec1 state << Tuple.second)

LowLevel.EllipticalArc mode arguments ->
let
Expand Down

0 comments on commit 66bf1a2

Please sign in to comment.