Created
November 3, 2016 09:08
-
-
Save amiuhle/8f02a18e9fc06dec2c069839b207f02e to your computer and use it in GitHub Desktop.
supportsOverlayBlendMode.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const supportsOverlayBlendMode = (() => { | |
const canvas = document.createElement('canvas') | |
canvas.width = canvas.height = 1 | |
const ctx = canvas.getContext('2d') | |
const bounds = [0, 0, 1, 1] | |
ctx.globalCompositeOperation = 'overlay' | |
ctx.fillStyle = '#000000' | |
ctx.fillRect(...bounds) | |
ctx.fillStyle = '#ffffff' | |
ctx.fillRect(...bounds) | |
const imageData = ctx.getImageData(...bounds) | |
return imageData.data[0] === 0 | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment