@@ -228,23 +228,35 @@ data Composite
228
228
| Xor
229
229
230
230
instance showComposite :: Show Composite where
231
- show SourceOver = " source-over "
232
- show SourceIn = " source-in "
233
- show SourceOut = " source-out "
234
- show SourceAtop = " source-atop "
235
- show DestinationOver = " destination-over "
236
- show DestinationIn = " destination-in "
237
- show DestinationOut = " destination-out "
238
- show DestinationAtop = " destination-atop "
239
- show Lighter = " lighter "
240
- show Copy = " copy "
241
- show Xor = " xor "
231
+ show SourceOver = " SourceOver "
232
+ show SourceIn = " SourceIn "
233
+ show SourceOut = " SourceOut "
234
+ show SourceAtop = " SourceAtop "
235
+ show DestinationOver = " DestinationOver "
236
+ show DestinationIn = " DestinationIn "
237
+ show DestinationOut = " DestinationOut "
238
+ show DestinationAtop = " DestinationAtop "
239
+ show Lighter = " Lighter "
240
+ show Copy = " Copy "
241
+ show Xor = " Xor "
242
242
243
243
foreign import setGlobalCompositeOperationImpl :: forall eff . Context2D -> String -> Eff (canvas :: Canvas | eff ) Context2D
244
244
245
245
-- | Set the current composite operation.
246
246
setGlobalCompositeOperation :: forall eff . Context2D -> Composite -> Eff (canvas :: Canvas | eff ) Context2D
247
- setGlobalCompositeOperation ctx composite = setGlobalCompositeOperationImpl ctx (show composite)
247
+ setGlobalCompositeOperation ctx composite = setGlobalCompositeOperationImpl ctx (toString composite)
248
+ where
249
+ toString SourceOver = " source-over"
250
+ toString SourceIn = " source-in"
251
+ toString SourceOut = " source-out"
252
+ toString SourceAtop = " source-atop"
253
+ toString DestinationOver = " destination-over"
254
+ toString DestinationIn = " destination-in"
255
+ toString DestinationOut = " destination-out"
256
+ toString DestinationAtop = " destination-atop"
257
+ toString Lighter = " lighter"
258
+ toString Copy = " copy"
259
+ toString Xor = " xor"
248
260
249
261
-- | Set the current global alpha level.
250
262
foreign import setGlobalAlpha :: forall eff . Context2D -> Number -> Eff (canvas :: Canvas | eff ) Context2D
@@ -388,11 +400,11 @@ data TextAlign
388
400
= AlignLeft | AlignRight | AlignCenter | AlignStart | AlignEnd
389
401
390
402
instance showTextAlign :: Show TextAlign where
391
- show AlignLeft = " left "
392
- show AlignRight = " right "
393
- show AlignCenter = " center "
394
- show AlignStart = " start "
395
- show AlignEnd = " end "
403
+ show AlignLeft = " AlignLeft "
404
+ show AlignRight = " AlignRight "
405
+ show AlignCenter = " AlignCenter "
406
+ show AlignStart = " AlignStart "
407
+ show AlignEnd = " AlignEnd "
396
408
397
409
foreign import textAlignImpl :: forall eff . Context2D -> Eff (canvas :: Canvas | eff ) String
398
410
@@ -414,7 +426,13 @@ foreign import setTextAlignImpl :: forall eff. Context2D -> String -> (Eff (canv
414
426
-- | Set the current text alignment.
415
427
setTextAlign :: forall eff . Context2D -> TextAlign -> Eff (canvas :: Canvas | eff ) Context2D
416
428
setTextAlign ctx textalign =
417
- setTextAlignImpl ctx (show textalign)
429
+ setTextAlignImpl ctx (toString textalign)
430
+ where
431
+ toString AlignLeft = " left"
432
+ toString AlignRight = " right"
433
+ toString AlignCenter = " center"
434
+ toString AlignStart = " start"
435
+ toString AlignEnd = " end"
418
436
419
437
-- | Text metrics:
420
438
-- |
@@ -482,14 +500,22 @@ foreign import drawImageFull :: forall eff. Context2D -> CanvasImageSource -> Nu
482
500
-- | Enumerates the different types of pattern repetitions.
483
501
data PatternRepeat = Repeat | RepeatX | RepeatY | NoRepeat
484
502
503
+ instance showPatternRepeat :: Show PatternRepeat where
504
+ show Repeat = " Repeat"
505
+ show RepeatX = " RepeatX"
506
+ show RepeatY = " RepeatY"
507
+ show NoRepeat = " NoRepeat"
508
+
485
509
foreign import createPatternImpl :: forall eff . CanvasImageSource -> String -> Context2D -> Eff (canvas :: Canvas | eff ) CanvasPattern
486
510
487
511
-- | Create a new canvas pattern (repeatable image).
488
512
createPattern :: forall eff . CanvasImageSource -> PatternRepeat -> Context2D -> Eff (canvas :: Canvas | eff ) CanvasPattern
489
- createPattern img Repeat = createPatternImpl img " repeat"
490
- createPattern img RepeatX = createPatternImpl img " repeat-x"
491
- createPattern img RepeatY = createPatternImpl img " repeat-y"
492
- createPattern img NoRepeat = createPatternImpl img " no-repeat"
513
+ createPattern img repeat = createPatternImpl img (toString repeat)
514
+ where
515
+ toString Repeat = " repeat"
516
+ toString RepeatX = " repeat-x"
517
+ toString RepeatY = " repeat-y"
518
+ toString NoRepeat = " no-repeat"
493
519
494
520
-- | Set the Context2D fillstyle to the CanvasPattern.
495
521
foreign import setPatternFillStyle :: forall eff . CanvasPattern -> Context2D -> Eff (canvas :: Canvas | eff ) Context2D
0 commit comments