@@ -213,8 +213,9 @@ setLineCap Round = setLineCapImpl "round"
213
213
setLineCap Square = setLineCapImpl " square"
214
214
setLineCap Butt = setLineCapImpl " butt"
215
215
216
- -- | Enumerates the different types of alpha composite operations.
216
+ -- | Enumerates the different types of composite operations and blend modes .
217
217
data Composite
218
+ -- Composite Operations
218
219
= SourceOver
219
220
| SourceIn
220
221
| SourceOut
@@ -227,24 +228,83 @@ data Composite
227
228
| Copy
228
229
| Xor
229
230
231
+ -- Blend Modes
232
+ | Multiply
233
+ | Screen
234
+ | Overlay
235
+ | Darken
236
+ | Lighten
237
+ | ColorDodge
238
+ | ColorBurn
239
+ | HardLight
240
+ | SoftLight
241
+ | Difference
242
+ | Exclusion
243
+ | Hue
244
+ | Saturation
245
+ | Color
246
+ | Luminosity
247
+
230
248
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"
249
+ show SourceOver = " SourceOver"
250
+ show SourceIn = " SourceIn"
251
+ show SourceOut = " SourceOut"
252
+ show SourceAtop = " SourceAtop"
253
+ show DestinationOver = " DestinationOver"
254
+ show DestinationIn = " DestinationIn"
255
+ show DestinationOut = " DestinationOut"
256
+ show DestinationAtop = " DestinationAtop"
257
+ show Lighter = " Lighter"
258
+ show Copy = " Copy"
259
+ show Xor = " Xor"
260
+ show Multiply = " Multiply"
261
+ show Screen = " Screen"
262
+ show Overlay = " Overlay"
263
+ show Darken = " Darken"
264
+ show Lighten = " Lighten"
265
+ show ColorDodge = " ColorDodge"
266
+ show ColorBurn = " ColorBurn"
267
+ show HardLight = " HardLight"
268
+ show SoftLight = " SoftLight"
269
+ show Difference = " Difference"
270
+ show Exclusion = " Exclusion"
271
+ show Hue = " Hue"
272
+ show Saturation = " Saturation"
273
+ show Color = " Color"
274
+ show Luminosity = " Luminosity"
242
275
243
276
foreign import setGlobalCompositeOperationImpl :: forall eff . Context2D -> String -> Eff (canvas :: Canvas | eff ) Context2D
244
277
245
278
-- | Set the current composite operation.
246
279
setGlobalCompositeOperation :: forall eff . Context2D -> Composite -> Eff (canvas :: Canvas | eff ) Context2D
247
- setGlobalCompositeOperation ctx composite = setGlobalCompositeOperationImpl ctx (show composite)
280
+ setGlobalCompositeOperation ctx composite = setGlobalCompositeOperationImpl ctx (toString composite)
281
+ where
282
+ toString SourceOver = " source-over"
283
+ toString SourceIn = " source-in"
284
+ toString SourceOut = " source-out"
285
+ toString SourceAtop = " source-atop"
286
+ toString DestinationOver = " destination-over"
287
+ toString DestinationIn = " destination-in"
288
+ toString DestinationOut = " destination-out"
289
+ toString DestinationAtop = " destination-atop"
290
+ toString Lighter = " lighter"
291
+ toString Copy = " copy"
292
+ toString Xor = " xor"
293
+ toString Multiply = " multiply"
294
+ toString Screen = " screen"
295
+ toString Overlay = " overlay"
296
+ toString Darken = " darken"
297
+ toString Lighten = " lighten"
298
+ toString ColorDodge = " color-dodge"
299
+ toString ColorBurn = " color-burn"
300
+ toString HardLight = " hard-light"
301
+ toString SoftLight = " soft-light"
302
+ toString Difference = " difference"
303
+ toString Exclusion = " exclusion"
304
+ toString Hue = " hue"
305
+ toString Saturation = " saturation"
306
+ toString Color = " color"
307
+ toString Luminosity = " luminosity"
248
308
249
309
-- | Set the current global alpha level.
250
310
foreign import setGlobalAlpha :: forall eff . Context2D -> Number -> Eff (canvas :: Canvas | eff ) Context2D
@@ -388,11 +448,11 @@ data TextAlign
388
448
= AlignLeft | AlignRight | AlignCenter | AlignStart | AlignEnd
389
449
390
450
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 "
451
+ show AlignLeft = " AlignLeft "
452
+ show AlignRight = " AlignRight "
453
+ show AlignCenter = " AlignCenter "
454
+ show AlignStart = " AlignStart "
455
+ show AlignEnd = " AlignEnd "
396
456
397
457
foreign import textAlignImpl :: forall eff . Context2D -> Eff (canvas :: Canvas | eff ) String
398
458
@@ -414,7 +474,13 @@ foreign import setTextAlignImpl :: forall eff. Context2D -> String -> (Eff (canv
414
474
-- | Set the current text alignment.
415
475
setTextAlign :: forall eff . Context2D -> TextAlign -> Eff (canvas :: Canvas | eff ) Context2D
416
476
setTextAlign ctx textalign =
417
- setTextAlignImpl ctx (show textalign)
477
+ setTextAlignImpl ctx (toString textalign)
478
+ where
479
+ toString AlignLeft = " left"
480
+ toString AlignRight = " right"
481
+ toString AlignCenter = " center"
482
+ toString AlignStart = " start"
483
+ toString AlignEnd = " end"
418
484
419
485
-- | Text metrics:
420
486
-- |
@@ -482,14 +548,22 @@ foreign import drawImageFull :: forall eff. Context2D -> CanvasImageSource -> Nu
482
548
-- | Enumerates the different types of pattern repetitions.
483
549
data PatternRepeat = Repeat | RepeatX | RepeatY | NoRepeat
484
550
551
+ instance showPatternRepeat :: Show PatternRepeat where
552
+ show Repeat = " Repeat"
553
+ show RepeatX = " RepeatX"
554
+ show RepeatY = " RepeatY"
555
+ show NoRepeat = " NoRepeat"
556
+
485
557
foreign import createPatternImpl :: forall eff . CanvasImageSource -> String -> Context2D -> Eff (canvas :: Canvas | eff ) CanvasPattern
486
558
487
559
-- | Create a new canvas pattern (repeatable image).
488
560
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"
561
+ createPattern img repeat = createPatternImpl img (toString repeat)
562
+ where
563
+ toString Repeat = " repeat"
564
+ toString RepeatX = " repeat-x"
565
+ toString RepeatY = " repeat-y"
566
+ toString NoRepeat = " no-repeat"
493
567
494
568
-- | Set the Context2D fillstyle to the CanvasPattern.
495
569
foreign import setPatternFillStyle :: forall eff . CanvasPattern -> Context2D -> Eff (canvas :: Canvas | eff ) Context2D
0 commit comments