Skip to content

Instantly share code, notes, and snippets.

@z-------------
Last active August 29, 2015 14:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save z-------------/86d18c21416a2bb4a5e4 to your computer and use it in GitHub Desktop.
Save z-------------/86d18c21416a2bb4a5e4 to your computer and use it in GitHub Desktop.
function avgRGB() {
var args = arguments;
var total = [0,0,0];
for (i=0; i<args.length; i++) {
total[0] += args[i][0];
total[1] += args[i][1];
total[2] += args[i][2];
}
for (i=0; i<total.length; i++) {
total[i] = Math.round(total[i] / args.length);
}
return total
}
// avgRGB([255,0,10],[0,0,255]) -> [128, 0, 133]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment