This file contains hidden or 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
async function getDominantColorViaWebGL(imageURL) { | |
return new Promise((resolve, reject) => { | |
const canvas = document.createElement('canvas'); | |
const gl = canvas.getContext('webgl'); | |
const img = new Image(); | |
img.crossOrigin = 'Anonymous'; | |
img.onload = function() { | |
canvas.width = canvas.height = 1; // Downsample to 1x1 pixel | |
// Setup texture and render image to canvas using WebGL |