Skip to main content

A comprehensive Python package for advanced color manipulation and analysis

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ColorKitv2-0.1.0.tar.gz (11.1 kB view hashes)

Uploaded Source

Built Distribution

ColorKitv2-0.1.0-py3-none-any.whl (11.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page