Skip to content

Commit

Permalink
lib/colors: simplify __color_rgb()
Browse files Browse the repository at this point in the history
Use normal `if`/`then`, use integer parameters, SC2004
  • Loading branch information
gaelicWizard committed Sep 18, 2021
1 parent 6908032 commit 9a74ef3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions themes/colors.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,13 @@ function __color_white {
}

function __color_rgb {
r=$1 && g=$2 && b=$3
[[ $r == $g && $g == $b ]] && echo $(( $r / 11 + 232 )) && return # gray range above 232
echo "8;5;$(( ($r * 36 + $b * 6 + $g) / 51 + 16 ))"
local -i r="$1" g="$2" b="$3"
if [[ "$r" == "$g" && "$g" == "$b" ]]
then # gray range above 232
echo "$(( r / 11 + 232 ))"
else
echo "8;5;$(( (r * 36 + b * 6 + g) / 51 + 16 ))"
fi
}

function __color {
Expand Down

0 comments on commit 9a74ef3

Please sign in to comment.