Created
January 5, 2024 17:08
-
-
Save yurkimus/aa13586e3009c26689cba198ee36d271 to your computer and use it in GitHub Desktop.
Average of 3-color tuples
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
const hexs = [ | |
// Karjala | |
[ '538854', 'be2928', '000000' ], | |
// Ludic | |
[ '529f54', 'be2928', '3d3b7b' ], | |
// Veps | |
[ '16b370', 'ffff00', '155cdc' ], | |
// Russian-side Finnish | |
[ 'ffd301', 'ef2d20', '0167b3' ], | |
// Izhorian | |
[ '000080', 'fed801', 'd70000' ], | |
// Votic | |
[ 'ffffff', '0099ff', 'ff0000' ], | |
// Siberian-Estonian | |
[ 'ffffff', 'ee0013', '150068' ] | |
] | |
const parseHex = flip(parseInt)(16) | |
const toHex = invoker(1, 'toString')(16) | |
const average = converge( | |
divide, | |
[ | |
reduce(useWith(add, [identity, parseHex]), 0), | |
length | |
] | |
) | |
const mix = compose( | |
map(compose(toHex, Math.round, average)), | |
transpose | |
) | |
mix(hexs) // => ["88ab3a", "c39013", "5224a3"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1: Original output
2. Manually corrected