Skip to content

Commit 7fa53f0

Browse files
committed
Merge pull request #34 from rgrempel/set-line-join
Implement setLineJoin
2 parents 0d687ab + 11a5c20 commit 7fa53f0

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
@@ -236,6 +236,25 @@ setLineCap :: forall eff. LineCap -> Context2D -> Eff (canvas :: Canvas | eff) C
236236

237237
Set the current line cap type.
238238

239+
#### `LineJoin`
240+
241+
``` purescript
242+
data LineJoin
243+
= BevelJoin
244+
| RoundJoin
245+
| MiterJoin
246+
```
247+
248+
Enumerates the different types of line join
249+
250+
#### `setLineJoin`
251+
252+
``` purescript
253+
setLineJoin :: forall eff. LineJoin -> Context2D -> Eff (canvas :: Canvas | eff) Context2D
254+
```
255+
256+
Set the current line join type.
257+
239258
#### `Composite`
240259

241260
``` purescript

src/Graphics/Canvas.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,15 @@ exports.setLineCapImpl = function(cap) {
155155
};
156156
};
157157

158+
exports.setLineJoinImpl = function(join) {
159+
return function(ctx) {
160+
return function() {
161+
ctx.lineJoin = join;
162+
return ctx;
163+
};
164+
};
165+
};
166+
158167
exports.setGlobalCompositeOperationImpl = function(ctx) {
159168
return function(op) {
160169
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()
@@ -45,6 +46,7 @@ module Graphics.Canvas
4546
, setMiterLimit
4647

4748
, setLineCap
49+
, setLineJoin
4850
, setGlobalCompositeOperation
4951
, setGlobalAlpha
5052

@@ -217,6 +219,19 @@ setLineCap Round = setLineCapImpl "round"
217219
setLineCap Square = setLineCapImpl "square"
218220
setLineCap Butt = setLineCapImpl "butt"
219221

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

0 commit comments

Comments
 (0)