Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/Graphics/Canvas.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,25 @@ setLineCap :: forall eff. LineCap -> Context2D -> Eff (canvas :: Canvas | eff) C

Set the current line cap type.

#### `LineJoin`

``` purescript
data LineJoin
= BevelJoin
| RoundJoin
| MiterJoin
```

Enumerates the different types of line join

#### `setLineJoin`

``` purescript
setLineJoin :: forall eff. LineJoin -> Context2D -> Eff (canvas :: Canvas | eff) Context2D
```

Set the current line join type.

#### `Composite`

``` purescript
Expand Down
9 changes: 9 additions & 0 deletions src/Graphics/Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@ exports.setLineCapImpl = function(cap) {
};
};

exports.setLineJoinImpl = function(join) {
return function(ctx) {
return function() {
ctx.lineJoin = join;
return ctx;
};
};
};

exports.setGlobalCompositeOperationImpl = function(ctx) {
return function(op) {
return function() {
Expand Down
15 changes: 15 additions & 0 deletions src/Graphics/Canvas.purs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Graphics.Canvas
, Composite(..)
, Dimensions()
, LineCap(..)
, LineJoin(..)
, Rectangle()
, ScaleTransform()
, TextMetrics()
Expand Down Expand Up @@ -44,6 +45,7 @@ module Graphics.Canvas
, setShadowColor

, setLineCap
, setLineJoin
, setGlobalCompositeOperation
, setGlobalAlpha

Expand Down Expand Up @@ -213,6 +215,19 @@ setLineCap Round = setLineCapImpl "round"
setLineCap Square = setLineCapImpl "square"
setLineCap Butt = setLineCapImpl "butt"

-- Note that we can't re-use `Round` from LineCap, so I've added `Join` to all of these

-- | Enumerates the different types of line join
data LineJoin = BevelJoin | RoundJoin | MiterJoin

foreign import setLineJoinImpl :: forall eff. String -> Context2D -> Eff (canvas :: Canvas | eff) Context2D

-- | Set the current line join type.
setLineJoin :: forall eff. LineJoin -> Context2D -> Eff (canvas :: Canvas | eff) Context2D
setLineJoin BevelJoin = setLineJoinImpl "bevel"
setLineJoin RoundJoin = setLineJoinImpl "round"
setLineJoin MiterJoin = setLineJoinImpl "miter"

-- | Enumerates the different types of composite operations and blend modes.
data Composite
-- Composite Operations
Expand Down