@@ -228,23 +228,35 @@ data Composite
228228 | Xor
229229
230230instance 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 "
242242
243243foreign import setGlobalCompositeOperationImpl :: forall eff . Context2D -> String -> Eff (canvas :: Canvas | eff ) Context2D
244244
245245-- | Set the current composite operation.
246246setGlobalCompositeOperation :: 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"
248260
249261-- | Set the current global alpha level.
250262foreign import setGlobalAlpha :: forall eff . Context2D -> Number -> Eff (canvas :: Canvas | eff ) Context2D
@@ -388,11 +400,11 @@ data TextAlign
388400 = AlignLeft | AlignRight | AlignCenter | AlignStart | AlignEnd
389401
390402instance 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 "
396408
397409foreign import textAlignImpl :: forall eff . Context2D -> Eff (canvas :: Canvas | eff ) String
398410
@@ -414,7 +426,13 @@ foreign import setTextAlignImpl :: forall eff. Context2D -> String -> (Eff (canv
414426-- | Set the current text alignment.
415427setTextAlign :: forall eff . Context2D -> TextAlign -> Eff (canvas :: Canvas | eff ) Context2D
416428setTextAlign 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"
418436
419437-- | Text metrics:
420438-- |
@@ -482,14 +500,22 @@ foreign import drawImageFull :: forall eff. Context2D -> CanvasImageSource -> Nu
482500-- | Enumerates the different types of pattern repetitions.
483501data PatternRepeat = Repeat | RepeatX | RepeatY | NoRepeat
484502
503+ instance showPatternRepeat :: Show PatternRepeat where
504+ show Repeat = " Repeat"
505+ show RepeatX = " RepeatX"
506+ show RepeatY = " RepeatY"
507+ show NoRepeat = " NoRepeat"
508+
485509foreign import createPatternImpl :: forall eff . CanvasImageSource -> String -> Context2D -> Eff (canvas :: Canvas | eff ) CanvasPattern
486510
487511-- | Create a new canvas pattern (repeatable image).
488512createPattern :: 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"
493519
494520-- | Set the Context2D fillstyle to the CanvasPattern.
495521foreign import setPatternFillStyle :: forall eff . CanvasPattern -> Context2D -> Eff (canvas :: Canvas | eff ) Context2D
0 commit comments