Module

Graphics.CanvasAction.Path

Package
purescript-canvas-action
Repository
artemisSystem/purescript-canvas-action

#PathData Source

type PathData = { cursor :: Vector2 Number, subpathStart :: Maybe (Vector2 Number) }

A record with data for the start of the current subpath and the location of the path cursor

#Path2D Source

data Path2D

A data type that contains a JavaScript Path2D object and PathData. The constructor is not exported because that would allow for desync between the JS Path2D and its data.

#getCursor Source

getCursor :: PathAction (Vector2 Number)

Get the cursor position of the path

#getSubpathStart Source

getSubpathStart :: PathAction (Maybe (Vector2 Number))

Get the start position of the current subpath

#moveTo Source

moveTo :: forall p. ToPos Number p => p -> PathAction Unit

Start a new sub-path at the given position

#closePath Source

closePath :: PathAction Unit

Draw a line from the current position to the starting position of the sub-path

#lineTo Source

lineTo :: forall p. ToPos Number p => p -> PathAction Unit

Draw a line from the last point in the sub-path to the given position

#quadraticCurveTo Source

quadraticCurveTo :: forall p. ToPos Number p => p -> p -> PathAction Unit

Adds a quadratic Bézier curve to the path. The first point is the control point and the second one is the end point.

#bezierCurveTo Source

bezierCurveTo :: forall p. ToPos Number p => p -> p -> p -> PathAction Unit

Adds a cubic Bézier curve to the path. The first two points are control points and the third one is the end point.

#ArcData Source

type ArcData = { center :: Vector2 Number, end :: Vector2 Number, nonZero :: Boolean, radius :: Number, start :: Vector2 Number }

#arcTo Source

arcTo :: forall p. ToPos Number p => p -> p -> Number -> PathAction ArcData

#arcTo_ Source

arcTo_ :: forall p. ToPos Number p => p -> p -> Number -> PathAction Unit

#ellipse Source

ellipse :: forall p. ToPos Number p => p -> Number -> Number -> Radians -> Radians -> Radians -> Boolean -> PathAction Unit

#arc Source

arc :: forall p. ToPos Number p => p -> Number -> Radians -> Radians -> Boolean -> PathAction Unit

#rect Source

rect :: forall r. ToRegion Number r => r -> PathAction Unit

#addPath Source

addPath :: Path2D -> PathAction Unit

Add the contents of a Path2D to the current path

#addPath' Source

addPath' :: DOMMatrix -> Path2D -> PathAction Unit

Add the contents of a Path2D to the current path, transforming it according to the provided DOMMatrix

#FillRule Source

data FillRule

Enumerates the different fill rules

Constructors

Instances

#runPath Source

runPath :: forall m. MonadEffect m => PathAction Unit -> m Path2D

Create a Path2D from a PathAction

#fill Source

fill :: forall m. MonadCanvasAction m => FillRule -> Path2D -> m Unit

Fill a Path2D

#fillWith Source

fillWith :: forall m r. MonadCanvasAction m => CanvasStyle r => r -> FillRule -> Path2D -> m Unit

Fill a Path2D with the given style

#stroke Source

stroke :: forall m. MonadCanvasAction m => Path2D -> m Unit

Stroke a Path2D

#strokeWith Source

strokeWith :: forall m r. MonadCanvasAction m => CanvasStyle r => r -> Path2D -> m Unit

Stroke a Path2D with the given style

#clip Source

clip :: forall m. MonadCanvasAction m => FillRule -> Path2D -> m Unit

Clip subsequent canvas drawings to a Path2D

#moveBy Source

moveBy :: forall p. ToPos Number p => p -> PathAction Unit

Move the cursor to a new position relative to its old position

#lineBy Source

lineBy :: forall p. ToPos Number p => p -> PathAction Unit

Draw a line from the last point in the sub-path to the given position, measured relative to its old position

#line Source

line :: forall p. ToPos Number p => p -> p -> PathAction Unit

Move to the first point and draw a line to the second point

#lines Source

lines :: forall p f. ToPos Number p => Foldable f => f p -> PathAction Unit

Append lines between all the specified points to the current subpath. First draws a line from the cursor position to the first point.

#polygon Source

polygon :: forall p f. ToPos Number p => Foldable f => f p -> PathAction Unit

Draw a polygon with the specified points. Starts and ends on the first point.

#circle Source

circle :: forall p. ToPos Number p => p -> Number -> PathAction Unit

Draw a circle with the specified center and radius. Ends on the rightmost point of the circle.

#arcBy Source

arcBy :: forall p. ToPos Number p => p -> p -> Number -> PathAction ArcData

Like arcTo, but the first point is relative to the cursor position, and the second point is relative to the first point

#arcBy_ Source

arcBy_ :: forall p. ToPos Number p => p -> p -> Number -> PathAction Unit

Like arcTo_, but the first point is relative to the cursor position, and the second point is relative to the first point

#abortSubpath Source

abortSubpath :: PathAction Unit

Aborts the current subpath and starts a new one at the cursor position