Skip to content

Commit 11a5c20

Browse files
committed
Implement setLineJoin
1 parent b0fc226 commit 11a5c20

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

docs/Graphics/Canvas.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,25 @@ setLineCap :: forall eff. LineCap -> Context2D -> Eff (canvas :: Canvas | eff) C
228228

229229
Set the current line cap type.
230230

231+
#### `LineJoin`
232+
233+
``` purescript
234+
data LineJoin
235+
= BevelJoin
236+
| RoundJoin
237+
| MiterJoin
238+
```
239+
240+
Enumerates the different types of line join
241+
242+
#### `setLineJoin`
243+
244+
``` purescript
245+
setLineJoin :: forall eff. LineJoin -> Context2D -> Eff (canvas :: Canvas | eff) Context2D
246+
```
247+
248+
Set the current line join type.
249+
231250
#### `Composite`
232251

233252
``` purescript

src/Graphics/Canvas.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,15 @@ exports.setLineCapImpl = function(cap) {
146146
};
147147
};
148148

149+
exports.setLineJoinImpl = function(join) {
150+
return function(ctx) {
151+
return function() {
152+
ctx.lineJoin = join;
153+
return ctx;
154+
};
155+
};
156+
};
157+
149158
exports.setGlobalCompositeOperationImpl = function(ctx) {
150159
return function(op) {
151160
return function() {

src/Graphics/Canvas.purs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module Graphics.Canvas
1111
, Composite(..)
1212
, Dimensions()
1313
, LineCap(..)
14+
, LineJoin(..)
1415
, Rectangle()
1516
, ScaleTransform()
1617
, TextMetrics()
@@ -44,6 +45,7 @@ module Graphics.Canvas
4445
, setShadowColor
4546

4647
, setLineCap
48+
, setLineJoin
4749
, setGlobalCompositeOperation
4850
, setGlobalAlpha
4951

@@ -213,6 +215,19 @@ setLineCap Round = setLineCapImpl "round"
213215
setLineCap Square = setLineCapImpl "square"
214216
setLineCap Butt = setLineCapImpl "butt"
215217

218+
-- Note that we can't re-use `Round` from LineCap, so I've added `Join` to all of these
219+
220+
-- | Enumerates the different types of line join
221+
data LineJoin = BevelJoin | RoundJoin | MiterJoin
222+
223+
foreign import setLineJoinImpl :: forall eff. String -> Context2D -> Eff (canvas :: Canvas | eff) Context2D
224+
225+
-- | Set the current line join type.
226+
setLineJoin :: forall eff. LineJoin -> Context2D -> Eff (canvas :: Canvas | eff) Context2D
227+
setLineJoin BevelJoin = setLineJoinImpl "bevel"
228+
setLineJoin RoundJoin = setLineJoinImpl "round"
229+
setLineJoin MiterJoin = setLineJoinImpl "miter"
230+
216231
-- | Enumerates the different types of composite operations and blend modes.
217232
data Composite
218233
-- Composite Operations

0 commit comments

Comments
 (0)