Skip to content

Instantly share code, notes, and snippets.

View vishalobrizum's full-sized avatar

vishalobrizum

View GitHub Profile
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