Material Palette Generator
A Python port of the Official Material Palette Generator.
This project reverse-engineers and refactors Google’s original algorithm to generate palette (extracted by edelstone/material-palette-generator) into clean, reusable Python code.
Features
- Generate full Material Design palettes from a single base hex color
- Produces primary, complementary, analogous and triadic variations
- Shows palette preview in image (
pillowlibrary required) - CLI support (
mpgcommand) - MIT Licensed
- No dependencies (pure Python)
Installation
Clone the repository:
git clone https://github.com/blacksteel3/material-palette-generator.git
cd material-palette-generator
Or install via pip:
pip install material-palettes-generator
Usage
import material_palette_generator as mpg
# generate palette from generic method
palettes = mpg.get_palettes("#E91E63") # optional `types` parameter to specify color types
print(palettes['Primary'])
print(palettes['Complementary'])
print(palettes['Analogous-1'])
print(palettes['Analogous-2'])
print(palettes['Triadic-1'])
print(palettes['Triadic-2'])
# or use specific method for specific type
primary_palette = mpg.get_primary_palette("#E91E63")
print(primary_palette)
# preview any palette (`pillow` library must be installed)
mpg.preview_palettes(primary_palette)
Command Line Interface (CLI)
After installing, you can use the mpg command directly from your terminal:
# Generate the primary palette
mpg "#3f51b5"
# Output as JSON
mpg "#3f51b5" --json
# Output as CSS
mpg "#3f51b5" --css
# Generate specific types
mpg "#3f51b5" --primary
mpg "#3f51b5" --complementary
mpg "#3f51b5" --analogous
mpg "#3f51b5" --triadic
# Combine multiple flags
mpg "#3f51b5" -p -t --json
# Or get all palettes
mpg "#3f51b5" --all
# Preview palette
mpg "#3f51b5" --show
# See all commands
mpg --help
Credits
- Google — for creating the Material Design color algorithm
- Michael Edelstone — for extracting the obfuscated JavaScript runtime code
- Black Steel — for reverse-engineering, renaming, and porting the algorithm to Python
Metadata
Release files for material-palettes-generator 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| material_palettes_generator-1.2.1.tar.gz | 17.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| material_palettes_generator-1.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.9 kB
Release files / material_palettes_generator-1.2.1.tar.gz
| Download URL | material_palettes_generator-1.2.1.tar.gz |
|---|---|
| Size | 17.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0db11f3f0d515d2901933a2afb232456c8f34a52eea50db9e4dcd5e1af62eab3
|
|
BLAKE2b-256 checksum How to use checksums |
9389bcc567ff1d923c1035e2145baddd6d789b08a801202243d51f94b65b0fc1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.13
|
Release files / material_palettes_generator-1.2.1-py3-none-any.whl
| Download URL | material_palettes_generator-1.2.1-py3-none-any.whl |
|---|---|
| Size | 17.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
205b52f53efe5f435e9c058d6eaaf464e1e345c943789e8e17bb0eded3e66723
|
|
BLAKE2b-256 checksum How to use checksums |
42ee675e317599b4f51978c28a86ece3864a60dd546b0b6e01e0fdfdcb91d40c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.13
|