Package: kolor
InstallationUsepipto install kolor:pipinstallkolorHow To Print Colored TextWe can print text with a colored foreground:fromkolorimportfg# Normal Colorsprint(fg.red+"Red Text")print(fg.green+"Green Text")print(fg.blue+"Blue Text")# Light Colorsprint(fg.lightred+"Light Red Text")print(fg.lightgreen+"Light Green Text")print(fg.lightBlue+"Light Blue Text")How it appears:We can also print text with a colored background:fromkolorimportbg# Normal Colorsprint(bg.red+"Red Background")print(bg.green+"Green Background")print(bg.blue+"Blue Background")# Light Colorsprint(bg.lightred+"Light Red Background")print(bg.lightgreen+"Light Green Background")print(bg.lightblue+"Light Blue Background")How it appears:Available colors for fg and bg:ColorNameblackredgreenyellowbluemagentacyangreydarkgreylightredlightgreenlightyellowlightbluelightmagentalightcyanwhiteHow To Print Text Using Customized ColorsWe can print using customized colors with Color Spaces RGB, HSL, HSV, Hex, CMYK:fromkolorimportfg,bg,reset# Foreground Colorsprint(fg.rgb(255,0,0)+"Red Text")print(fg.hsl(30,100,50)+"Orange Text")print(fg.hsv(60,100,100)+"Yellow Text")print(fg.hex('#00FF00')+"Green Text")print(fg.cmyk(100,0,0,0)+"Cyan Text"+reset.fg)# Background Colorsprint(bg.rgb(255,0,0)+"Red Background")print(bg.hsl(30,100,50)+"Orange Background")print(bg.hsl(60,100,100)+"Yellow Background")print(bg.hex('#00FF00')+"Green Background")print(bg.cmyk(100,0,0,0)+"Cyan Background"+reset.bg)How it appears:How To Print Stylized TextWe can also print Stylized Text:fromkolorimportstyle# Stylesprint(style.bold+"Bold Text"+style.reset.bold)print(style.underline+"Underlined Text"+style.reset.underline)How it appears:Available Styles:1. bold
2. dim
3. italic
4. underline
5. blink
6. rapidblink
7. reverse
8. invisible
9. strikethroughNote: Some styles may not be supported in all terminals, and may have a different function.How To Use The HelperHow To Check Color Model Values:We can check whether HSL, HSV, Hex, CMYK and RGB Values are correct:If the given color space values are correct, It will return True or else False.fromkolor.helperimportcheck# Valid Valuesprint(check.rgb(255,128,0))print(check.hsl(30,100,50))print(check.hsv(30,100,100))print(check.hex('#FF8000'))print(check.cmyk(0,50,100,0))# Invalid Valuesprint(check.rgb(300,128,0))print(check.hsl(400,100,50))print(check.hsv(400,100,100))print(check.hex('#ZZ8000'))print(check.cmyk(0,50,200,0))The first five lines will return True as the given values are correct but the next five will return False as the given values are incorrect.Valid Color Model Ranges:RGB = R - (0, 255), G - (0, 255), B - (0, 255)
HSL = H - (0.0, 360.0), S - (0.0, 100.0), L - (0.0, 100.0)
HSV = H - (0.0, 360.0), S - (0.0, 100.0), V - (0.0, 100.0)
Hex = Numbers 0 to 9 and Letters A to F with Length of 6 Characters
CMYK = C - (0, 100), M - (0, 100), Y - (0, 100), K - (0, 100)How To Convert Values Between Color Models:We can convert HSL, HSV, Hex, CMYK to RGB and back:fromkolor.helperimportconvert# Color Models To RGBprint(convert.hsl_to_rgb(30,100,50))print(convert.hsv_to_rgb(30,100,100))print(convert.hex_to_rgb('#FF8000'))print(convert.cmyk_to_rgb(0,50,100,0))# RGB To Color Modelsprint(convert.rgb_to_hsl(255,0,0))print(convert.rgb_to_hsv(255,128,0))print(convert.rgb_to_hex(255,255,0))print(convert.rgb_to_cmyk(0,255,0))Output:Thanks!ContributeIf you have any suggestions, create a pull requesthere.Report BugsIf you find any bugs, please report themhere.