Last active
August 29, 2015 14:02
-
-
Save z-------------/86d18c21416a2bb4a5e4 to your computer and use it in GitHub Desktop.
This file contains 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
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