Skip to content

Instantly share code, notes, and snippets.

@amiuhle
Created November 3, 2016 09:08
Show Gist options
  • Save amiuhle/8f02a18e9fc06dec2c069839b207f02e to your computer and use it in GitHub Desktop.
Save amiuhle/8f02a18e9fc06dec2c069839b207f02e to your computer and use it in GitHub Desktop.
supportsOverlayBlendMode.js
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