Skip to main content

Generate Material Design color palettes in Python

Project description

Material Palette Generator

Palette Preview

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 (pillow library required)
  • CLI support (mpg command)
  • 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

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_palettes_generator-1.2.1.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

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

material_palettes_generator-1.2.1-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file material_palettes_generator-1.2.1.tar.gz.

File metadata

File hashes

Hashes for material_palettes_generator-1.2.1.tar.gz
Algorithm Hash digest
SHA256 0db11f3f0d515d2901933a2afb232456c8f34a52eea50db9e4dcd5e1af62eab3
MD5 018cb9d57d21a3c1c3caea2935abd077
BLAKE2b-256 9389bcc567ff1d923c1035e2145baddd6d789b08a801202243d51f94b65b0fc1

See more details on using hashes here.

File details

Details for the file material_palettes_generator-1.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for material_palettes_generator-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 205b52f53efe5f435e9c058d6eaaf464e1e345c943789e8e17bb0eded3e66723
MD5 a49a894c08c9f47db3777900d6d82db5
BLAKE2b-256 42ee675e317599b4f51978c28a86ece3864a60dd546b0b6e01e0fdfdcb91d40c

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