UNPKG
color-sort
Version:
latest (0.0.1)
0.0.1
A simple lib that sorts colors by perception.
github.com/javierbyte/color-sort
javierbyte/color-sort
color-sort
/
index.js
9 lines
(7 loc)
•
229 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
var
tinycolor =
require
(
'tinycolor2'
)
function
sortColors
(
colorArray
) {
return
colorArray.
sort
(
function
(
colorA, colorB
) {
return
tinycolor
(colorA).
toHsv
().
h
-
tinycolor
(colorB).
toHsv
().
h
}) }
module
.
exports
= sortColors