YBee24 / Yasmina-and-Lucien-Shell-Problem-Project-Friday-26-July

0 stars 0 forks source link

think about styling the output #2

Open Luciensday opened 3 months ago

Luciensday commented 3 months ago
YBee24 commented 3 months ago

To use Pantone colors in a Linux Bash script, you'll need to convert them to their equivalent RGB values and then use escape sequences to display them in the terminal. Since Pantone colors are proprietary, they don't have direct representations in terminals, but we can approximate them using their RGB values.

Below are the RGB values and the corresponding escape sequences for the specified Pantone colors:

Pantone Colors and RGB Values

Pantone 203 RGB: (239, 187, 204) Hex: #EFBBCC

Pantone 204 RGB: (234, 169, 192) Hex: #EAA9C0

Pantone 205 RGB: (229, 115, 159) Hex: #E5739F

Pantone 206 RGB: (209, 52, 91) Hex: #D1345B

Pantone 207 RGB: (182, 28, 67) Hex: #B61C43

Pantone 209 RGB: (134, 28, 49) Hex: #861C31

Displaying Colors in Bash

To display colors in the terminal, we can use the ANSI escape codes. Here's how you can define and use these colors in a Bash script:

YBee24 commented 3 months ago

!/bin/bash

Function to convert RGB to a 256-color escape sequence

rgb_to_ansi() { local r=$1 local g=$2 local b=$3 local ansi=$((16 + (r / 43) 36 + (g / 43) 6 + (b / 43))) echo "$ansi" }

Define Pantone colors using RGB to ANSI conversion

PANTONE_203=$(rgb_to_ansi 239 187 204) PANTONE_204=$(rgb_to_ansi 234 169 192) PANTONE_205=$(rgb_to_ansi 229 115 159) PANTONE_206=$(rgb_to_ansi 209 52 91) PANTONE_207=$(rgb_to_ansi 182 28 67) PANTONE_209=$(rgb_to_ansi 134 28 49)

Display colors

echo -e "\033[38;5;${PANTONE_203}mPantone 203\033[0m: RGB(239, 187, 204)" echo -e "\033[38;5;${PANTONE_204}mPantone 204\033[0m: RGB(234, 169, 192)" echo -e "\033[38;5;${PANTONE_205}mPantone 205\033[0m: RGB(229, 115, 159)" echo -e "\033[38;5;${PANTONE_206}mPantone 206\033[0m: RGB(209, 52, 91)" echo -e "\033[38;5;${PANTONE_207}mPantone 207\033[0m: RGB(182, 28, 67)" echo -e "\033[38;5;${PANTONE_209}mPantone 209\033[0m: RGB(134, 28, 49)"

Reset the color

echo -e "\033[0m"