Skip to content

Instantly share code, notes, and snippets.

View zekrom-vale's full-sized avatar
🐲
Dragon

Shawn zekrom-vale

🐲
Dragon
View GitHub Profile
@zekrom-vale
zekrom-vale / length
Last active June 1, 2017 14:07 — forked from olvado/getAverageColourAsRGB.js
Get the average colour of an image in javascript using getImageData in CANVAS
function getAvColor (img) {
var canvas = document.createElement('canvas'),
context = canvas.getContext && canvas.getContext('2d'),
rgb,
pixelInterval = 5, // Rather than inspect every single pixel in the image inspect every 5th pixel
count = 0,
data, length,
i = -4;
// return the base colour for non-compliant browsers