Skip to content

Instantly share code, notes, and snippets.

@rsms

rsms/bla.js Secret

Created March 25, 2020 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rsms/55292141a53c4b8b068912293c3dca76 to your computer and use it in GitHub Desktop.
Save rsms/55292141a53c4b8b068912293c3dca76 to your computer and use it in GitHub Desktop.
let pixels = canvas.context2D().getImageData(0, 0, canvas.width, canvas.height).data
let pxcount = canvas.width * canvas.height
let stride = (pixels.length / pxcount) >>> 0 // bytes per pixel
let dominantColor = (
stride != 4 ? [255,255,255,255] :
dominantColorRGBA(pixels, pxcount, stride * Math.max(1, scale))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment