1
0
mirror of https://github.com/nostalgic-css/NES.css.git synced 2025-08-31 01:39:50 +02:00

refactor(icons): automatically pick main color

ref #60
This commit is contained in:
Joshua Rouzer
2018-12-09 22:01:01 -05:00
parent 55a6e3ac00
commit d5173b9ad2
6 changed files with 28 additions and 10 deletions

View File

@@ -2,7 +2,25 @@
$ret: "";
$moz: "";
@if ($default-color == null) {
$default-color: nth($colors, 1);
// count number of each color in matrix and decide main color by highest count
$matrix-colors: ();
$counts: ();
@each $row in $matrix {
@each $item in $row {
@if $item != 0 {
$index: index($matrix-colors, $item);
@if not $index {
$matrix-colors: append($matrix-colors, $item);
$counts: append($counts, 1);
} @else {
$count: nth($counts, $index) + 1;
$counts: set-nth($counts, $index, $count);
}
}
}
}
// use index of the highest count to get the corresponding matrix color
$default-color: nth($colors, nth($matrix-colors, index($counts, max($counts...))));
}
@for $i from 1 through length($matrix) {