Skip to content

Commit e2b19f8

Browse files
committed
Add support for new canvas blend modes
1 parent ac6646c commit e2b19f8

File tree

2 files changed

+67
-4
lines changed

2 files changed

+67
-4
lines changed

docs/Graphics/Canvas.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,24 @@ data Composite
243243
| Lighter
244244
| Copy
245245
| Xor
246-
```
247-
248-
Enumerates the different types of alpha composite operations.
246+
| Multiply
247+
| Screen
248+
| Overlay
249+
| Darken
250+
| Lighten
251+
| ColorDodge
252+
| ColorBurn
253+
| HardLight
254+
| SoftLight
255+
| Difference
256+
| Exclusion
257+
| Hue
258+
| Saturation
259+
| Color
260+
| Luminosity
261+
```
262+
263+
Enumerates the different types of composite operations and blend modes.
249264

250265
##### Instances
251266
``` purescript

src/Graphics/Canvas.purs

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,9 @@ setLineCap Round = setLineCapImpl "round"
213213
setLineCap Square = setLineCapImpl "square"
214214
setLineCap Butt = setLineCapImpl "butt"
215215

216-
-- | Enumerates the different types of alpha composite operations.
216+
-- | Enumerates the different types of composite operations and blend modes.
217217
data Composite
218+
-- Composite Operations
218219
= SourceOver
219220
| SourceIn
220221
| SourceOut
@@ -227,6 +228,23 @@ data Composite
227228
| Copy
228229
| Xor
229230

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+
230248
instance showComposite :: Show Composite where
231249
show SourceOver = "SourceOver"
232250
show SourceIn = "SourceIn"
@@ -239,6 +257,21 @@ instance showComposite :: Show Composite where
239257
show Lighter = "Lighter"
240258
show Copy = "Copy"
241259
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"
242275

243276
foreign import setGlobalCompositeOperationImpl :: forall eff. Context2D -> String -> Eff (canvas :: Canvas | eff) Context2D
244277

@@ -257,6 +290,21 @@ setGlobalCompositeOperation ctx composite = setGlobalCompositeOperationImpl ctx
257290
toString Lighter = "lighter"
258291
toString Copy = "copy"
259292
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"
260308

261309
-- | Set the current global alpha level.
262310
foreign import setGlobalAlpha :: forall eff. Context2D -> Number -> Eff (canvas :: Canvas | eff) Context2D

0 commit comments

Comments
 (0)