Skip to main content

A package for working with colors, including retrieval, random selection without repeats, and hex-to-RGB conversion.

Project description

PrettyColors

PrettyColors is a lightweight Python package that provides a simple interface to access a comprehensive palette of Material Design colors. Use it to easily retrieve hex codes for colors, list available shades, and even generate random colors with options for unique (non-repeating) selections.

Features

  • Easy Color Retrieval: Access color hex codes by name, with automatic defaulting to a mid-range shade (500) when a specific shade isn’t provided.
  • Flexible Access Methods: Retrieve colors using attribute or dictionary-style access.
  • Random Color Generation: Pick random colors, with an option to avoid repeats until the entire palette has been cycled through.
  • Color Listing: Get a full list of available color keys from the Material Design palette.

Installation

Install PrettyColors using pip:

pip install pretty_colors

Quick Start

Below is a quick example to get you started:

from pretty_colors import colors

# Retrieve a specific color; if no shade is specified, defaults to the "500" shade.
print(colors.RED)      # Equivalent to colors.RED500

# Retrieve a specific shade of a color.
print(colors.get("BLUE100"))

# Access colors using dictionary-style access.
print(colors["GREEN"]) # Defaults to GREEN500

# List all available colors.
print(colors.list_colors())

# Generate a random color (duplicates allowed).
print(colors.random())

# Generate a random color ensuring uniqueness until all colors have been used.
print(colors.random(repeat=False))

API Reference

Attribute Access

  • Usage: colors.COLOR_NAME
  • Behavior: If you access a color without specifying a shade (digits), the package appends "500" by default.
  • Example:
print(colors.PINK)      # Retrieves PINK500
print(colors.PURPLE200) # Retrieves PURPLE200

Availble Names

This is a list of colors base names.

AMBER
BLACK
BLUE 
BLUEGREY 
BROWN 
CYAN 
DEEPORANGE 
DEEPPURPLE 
GREEN 
GREY 
INDIGO 
LIGHTBLUE 
LIGHTGREEN 
LIME 
ORANGE 
PINK 
PURPLE 
RED
TEAL 
WHITE 
YELLOW

get(name)

  • Description: Retrieves the hex code for the given color name. If the name does not include a shade, "500" is appended.
  • Example:
    print(colors.get("RED"))    # Returns hex code for RED500
    print(colors.get("RED100")) # Returns hex code for RED100

list_colors()

  • Description: Returns a list of all available color keys.
  • Example:
print(colors.list_colors())

random(repeat=False)

  • Description: Returns a random color’s hex code. If repeat is False, the method ensures no color is repeated until all colors have been selected.
  • Example:
print(colors.random())             # Random color (may repeat)
print(colors.random(repeat=False)) # Random unique color

reset_available_colors()

  • Description: Resets the list of available colors for unique random selection.
  • Example:
colors.reset_available_colors()

Contributing

Contributions are welcome! To contribute:

  • Fork the repository.
  • Create a feature branch (e.g., git checkout -b feature/new-feature).
  • Commit your changes (git commit -am 'Add new feature').
  • Push your branch (git push origin feature/new-feature).
  • Open a Pull Request with your changes.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements

This package leverages the Material Design color palette and provides a simple yet powerful interface to work with these colors in your Python projects.

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

pretty_colors-0.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pretty_colors-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file pretty_colors-0.1.0.tar.gz.

File metadata

  • Download URL: pretty_colors-0.1.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for pretty_colors-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a19dd099847babaddc3a0f3e11e783f69bb3a742fa62ad4e8a997da6aa6c3879
MD5 53cee9cde0ac11656b4d752cc812e78d
BLAKE2b-256 610570f4ccfb301a89f6a84b6e4f798f8da5d84123e323c1e598d26d8ec3d1d1

See more details on using hashes here.

File details

Details for the file pretty_colors-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pretty_colors-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for pretty_colors-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05d08b079d68e41328967c43ab3aaa9cb2d673d259fb908438e17f5b569b2f1d
MD5 a922ca3b6abadff5c36a1a78b4994208
BLAKE2b-256 ab83d4efdb4de48cab42ed3a38b7ff7abab4ca9dc4b4d02c8befee6997cfa5cf

See more details on using hashes here.

Supported by

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