Skip to content

Commit

Permalink
Merge pull request #34 from rgrempel/set-line-join
Browse files Browse the repository at this point in the history
Implement setLineJoin
  • Loading branch information
paf31 committed May 11, 2016
2 parents 0d687ab + 11a5c20 commit 7fa53f0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/Graphics/Canvas.md
Expand Up @@ -236,6 +236,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
Expand Up @@ -155,6 +155,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
Expand Up @@ -11,6 +11,7 @@ module Graphics.Canvas
, Composite(..)
, Dimensions()
, LineCap(..)
, LineJoin(..)
, Rectangle()
, ScaleTransform()
, TextMetrics()
Expand Down Expand Up @@ -45,6 +46,7 @@ module Graphics.Canvas
, setMiterLimit

, setLineCap
, setLineJoin
, setGlobalCompositeOperation
, setGlobalAlpha

Expand Down Expand Up @@ -217,6 +219,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

0 comments on commit 7fa53f0

Please sign in to comment.