Skip to main content

ColorKit

ColorKit is a comprehensive Python library designed for versatile color conversions, manipulations, and more. It simplifies working with various color spaces such as RGB, HEX, CMYK, HSL, LAB, LUV, XYZ, YIQ, HSV, YUV, YCbCr, LCH, and LMS. Whether you're developing applications in web development, data analysis, or scientific computing, ColorKit offers a robust set of tools to enhance your project's color processing capabilities.

With ColorKit, you can easily convert colors between different color spaces, generate random colors, manipulate color palettes, and perform color-related operations. It provides functions to convert colors from one color space to another, generate random colors in different color spaces, print colored text to the terminal, select colors from a color palette, view colors in a window, and more.

ColorKit's extensive documentation provides detailed examples and usage instructions for each color space conversion and feature. It also includes a list of supported color spaces and their corresponding conversion functions. Installation is straightforward using pip, making it easy to integrate ColorKit into your Python projects.

Start leveraging the power of ColorKit to enhance your color processing capabilities in Python today!

Features

  • Color Space Conversions: Easily convert between popular and specialized color spaces.
  • Random Color Generator: Generate random colors in various color spaces.
  • Colored Terminal Outputs/Logs: Print colored text to the terminal.
  • Color Palette: Select colors from a color palette.
  • Color Viewer: View any color in a window.
  • Color Names Converter: Get the color value from a color name.

Installation

pip3 install ColorKit

Documentation

Color Space Conversions Example

import ColorKit as ck

# Convert RGB to HEX
# NOTE: The RGB values must be in a tuple.
hex_color = ck.rgb_to_hex((255, 0, 0))
# NOTE: The HEX value will be a string.
rgb_color = ck.hex_to_rgb("#FF0000")

# Convert RGB to CMYK
cmyk_color = ck.rgb_to_cmyk((255, 0, 0))
rgb_color = ck.cmyk_to_rgb((0, 1, 1, 0))

# You can also specify the decimal places for the returned values. as the second argument.
# NOTE: You can only specify the decimal places for colors converting from RGB to another color space.
hsl_color = ck.rgb_to_xyz((255, 0, 0), 2)
# Output: (41.24, 21.26, 1.93)

You can use the same approach for the following color spaces:

List of color spaces rgb_to_hex, hex_to_rgb, rgb_to_hsl, hsl_to_rgb, rgb_to_cmyk, cmyk_to_rgb, rgb_to_yuv, yuv_to_rgb, rgb_to_yiq, yiq_to_rgb, rgb_to_ycbcr, ycbcr_to_rgb, rgb_to_xyz, xyz_to_rgb, rgb_to_lab, lab_to_rgb, rgb_to_luv, luv_to_rgb, rgb_to_lch, lch_to_rgb, rgb_to_lms, lms_to_rgb, rgb_to_hsv, hsv_to_rgb, rgb_to_hsv, hsv_to_rgb, rgb_to_xyz

NOTE: All the color spaces are in the form of tuples (Except HEX).

Random Color Generator Example

import ColorKit as ck

color = ck.RandomColor()
hex = color.hex()
rgb = color.rgb()

# You can also view the color in a window.
color.view()

Colored Terminal Outputs/Logs Example

To print a log message you can use the folowing code:

from ColorKit import Warning, Error, Success,Info

# Create a warning message in the terminal
Warning("This is a warning message",True,True)

# Create an error message in the terminal
Error("This is an error message",True,True)

# Create a success message in the terminal
Success("This is a success message",True,True)

# Create an info message in the terminal
Info("This is an info message",True,True)

The first argument is the message, the second argument is if the message is bold, and the third argument is if the full message is colored or only the WARNING/ERROR/SUCCESS/INFO part. Use True or False for the second and third arguments.

Custom Colored Terminal Outputs Example

from ColorKit import Print

# Print a message in the terminal with a custom color (HEX, RGB, or color name)
# Make sure you you use Print (with a capital P) instead of print.
Print("This is a custom message", "red")
Print("This is a custom message", "#FF0000")
Print("This is a custom message", (255, 0, 0))

# You can also add a style to the message
# (bold, underline, italic, strike, overline, inverse, crossed)
Print("This is a custom message", "red", "bold")

# You can also add a background color to the message
Print("This is a custom message", "red", "bold", "blue")

The first argument is the message, the second argument is the color, the third argument is the style, and the fourth argument is the background color.

Color Palette Example

import ColorKit as ck

# Open the color palette window and select a color.
picker = ck.ColorPicker()

# Pick the color format the color will be returned in. (RGB/HEX/HSL/CMYK)
color = picker.rgb()

# Then you can use the color as you wish.
# For example, you can print the color to the terminal.
print(color)

Color Viewer Example

from ColorKit import ViewColor

# Select a color to view in a window.
color = (255, 0, 0)

# Open the color viewer window.
ViewColor(color)

Color Names To Color Value Example

import ColorKit as ck

# Get the color value from a color name in a RGB format. (You can also use HEX)
color = ck.Color("red").rgb()
print(color)

# Output: (255, 0, 0)

List of all available colors

License

ColorKit is released under the MIT License - see the LICENSE file for details.

Contributing

If you would like to contribute to ColorKit, please read the CONTRIBUTING.md

Release files for ColorKit 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ColorKit 0.1.0
File Size Uploaded
ColorKit-0.1.0.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ColorKit 0.1.0
File Interpreter ABI Platform
ColorKit-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.0 kB

Release files / ColorKit-0.1.0.tar.gz

Download URL ColorKit-0.1.0.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
240856c0ae155ff8b08d6eceb71bccaef59ee9677a0c02ac30debef9e22075fb
BLAKE2b-256 checksum
How to use checksums
ec7b798375215b9b858ecf27e50f80201165bcffb3bd05fe07591206475cd8c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.1

Release files / ColorKit-0.1.0-py3-none-any.whl

Download URL ColorKit-0.1.0-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6361f456ea629787201ec127343e0a55e6c5eedea088ad0bfac7bb67508633b4
BLAKE2b-256 checksum
How to use checksums
1e3db39be0fe42706f5270823431c8646e77dc613addeed370fde510549927e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.1

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.5

1 release file

0.0.2

1 release file

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page