Skip to main content

Google's original 2014 Material Design color palettes as a Python library

Project description

material-color-palette

Google's original 2014 Material Design color palettes as a Python library package.

Because I wanted to use the palettes in some of my projects, but didn't want to copy-paste values, and couldn't find an existing implementation that was simple and complete.

Fully type-hinted and with a test suite.

Installation

Not yet available on PyPI, so install from GitHub, e.g.:

pip install git+https://github.com/elliot-100/material-color-palette

I recommend installing a specific version, e.g.:

pip install git+https://github.com/elliot-100/material-color-palette@v0.3.0

Usage

>>> from material_color_palette import Color
>>> MY_COLOR = Color("red", 700)
>>> MY_COLOR
Color(name='red', shade=700, rgb=(211, 47, 47))

# Use RGB triplet representation in e.g. pygame/pygame-ce:
>>> MY_COLOR.rgb
(211, 47, 47)

# Use hex string representation in e.g. Matplotlib:
>>> MY_COLOR.hex
'#d32f2f'

# r, g, b properties should cover any other need:
>>> f"r={MY_COLOR.r/255}, g={MY_COLOR.g/255}, b={MY_COLOR.b/255}, a=1.0"
'r=0.8274509803921568, g=0.1843137254901961, b=0.1843137254901961, a=1.0'

# Accent colours use the original notation, so shade value is a string  
>>> Color("pink", "a100")

# You can use strings for non-accented colours too, if you want to be consistent
>>> Color("teal", "100")

# Useful, contextual error messages:
>>> Color("lime_green") 
Traceback (most recent call last):
...
ValueError: 'lime_green' isn't a valid Material color name. Allowed values: 'amber',
'black', 'blue', 'blue gray', 'blue_gray', 'brown', 'cyan', 'deep orange', 'deep purple',
'deep_orange', 'deep_purple', 'gray', 'green', 'indigo', 'light blue', 'light green',
'light_blue', 'light_green', 'lime', 'orange', 'pink', 'purple', 'red', 'teal', 'white',
'yellow'.

>>> Color("lime")
Traceback (most recent call last):
...
ValueError: Shade must be specified for Material color 'lime'.

>>> Color("yellow", 950)
Traceback (most recent call last):
...
ValueError: 950 isn't a valid shade for Material color 'yellow'. Allowed values: 50,
100, 200, 300, 400, 500, 600, 700, 800, 900, 'a100', 'a200', 'a400', 'a700'.


>>> Color("gray", "a200")
Traceback (most recent call last):
...
ValueError: 'a200' isn't a valid shade for Material color 'gray'. Allowed values: 50,
100, 200, 300, 400, 500, 600, 700, 800, 900.

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

material_color_palette-0.4.0.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

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

material_color_palette-0.4.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file material_color_palette-0.4.0.tar.gz.

File metadata

File hashes

Hashes for material_color_palette-0.4.0.tar.gz
Algorithm Hash digest
SHA256 3604998fcdddc0bf9c6b23608dc2500619df82853dd923cb1a31ec753250349f
MD5 4de9bf45b841c7a273dc9e230d82dce5
BLAKE2b-256 c4173a19703c46289db2a4c0bf47fbe1b00595ce9879a6bc0cff76174d0eee78

See more details on using hashes here.

File details

Details for the file material_color_palette-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for material_color_palette-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 79e9f094cf20ea8df99cc2dd3cbcc803d080c7938a8bfcbd67b0f30e7a488e73
MD5 de87081c4df542f9c8a8d44b66ae7f17
BLAKE2b-256 4cb13e7c6c6ec8c1e3b73dda2faa655f12ddefe661d40c7680aab9cc0d4d36e2

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