From 11a5c203d5c23b930d1fd1dd08be38bc3fc90961 Mon Sep 17 00:00:00 2001 From: Ryan Rempel Date: Mon, 9 May 2016 16:15:57 -0500 Subject: [PATCH] Implement setLineJoin --- docs/Graphics/Canvas.md | 19 +++++++++++++++++++ src/Graphics/Canvas.js | 9 +++++++++ src/Graphics/Canvas.purs | 15 +++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/docs/Graphics/Canvas.md b/docs/Graphics/Canvas.md index d0be550..fe9d65c 100644 --- a/docs/Graphics/Canvas.md +++ b/docs/Graphics/Canvas.md @@ -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 diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index f7113f4..c468934 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -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() { diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 0029ec3..9e2c000 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -11,6 +11,7 @@ module Graphics.Canvas , Composite(..) , Dimensions() , LineCap(..) + , LineJoin(..) , Rectangle() , ScaleTransform() , TextMetrics() @@ -44,6 +45,7 @@ module Graphics.Canvas , setShadowColor , setLineCap + , setLineJoin , setGlobalCompositeOperation , setGlobalAlpha @@ -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