La til en parser for å gjøre det enklere å scanne farger med Linshang LS171
[einar-bin] / colorscan.sh
1 #!/bin/bash
2 n=1
3 while read scan; do
4 if [ "${n}" != 1 ]; then
5 echo ""
6 fi
7 echo "Scan ${n}:"
8 lab=$(echo "${scan}" | jq -cr '.scan.lab | join(", ")')
9 lch=$(echo "${scan}" | jq -cr '.scan.lch | join(", ")')
10 rgb=$(echo "${scan}" | jq -cr '.scan.rgb | join(", ")')
11 r=$(echo "${rgb}" | cut -f 1 -d "," | tr -d " ")
12 g=$(echo "${rgb}" | cut -f 2 -d "," | tr -d " ")
13 b=$(echo "${rgb}" | cut -f 3 -d "," | tr -d " ")
14 rH=$(printf "%x\n" ${r})
15 gH=$(printf "%x\n" ${g})
16 bH=$(printf "%x\n" ${b})
17 for i in {1..10}; do
18 echo -e "\033[48;2;${r};${g};${b}m \e[0m"
19 done
20 echo "L*a*b: ${lab}"
21 echo "L*C*h: ${lch}"
22 echo "RGB: ${rgb}"
23 echo "HEX: #${rH}${gH}${bH}"
24 ((n++))
25 done < <(bluecolor --format json)