Create color gradients based on list-like input data
Project description
Gradpyent, a Python Gradient Generator
Gradpyent is a Python package for generating color gradients based on list-like inputs and start/end color values. The generated gradients are ideal for data visualization, user interfaces, or anywhere you want to convert a list of values into a color gradient.
This package allows you to specify colors in a variety of formats including RGB, HTML, and KML, giving you the flexibility to match your specific needs.
The gradient generation algorithm automatically scales input values outside the range of 0-1, ensuring the generated gradient remains consistent and visually pleasing.
Table of Contents
Installation
You can install Gradpyent directly from PyPI:
pip install gradpyent
Usage
Basic usage:
from gradpyent.gradient import Gradient
# Define the start and end colors as RGB, HTML, or KML
start_color = 'rgb(255,0,0)' # Red in RGB
end_color = '#0000ff' # Blue in HTML
# Instantiate the gradient generator, opacity is optional (only used for KML)
gg = Gradient(gradient_start=start_color, gradient_end=end_color, opacity=1.0)
# Define the input list
input_list = [0, 0.5, 1]
# Generate the gradient
gradient = gg.get_gradient_series(series=input_list, fmt='html')
print(gradient)
Examples
Here are some more examples demonstrating how to use different color formats and list inputs:
- RGB colors:
start_color = 'rgb(255,0,0)' # Red
end_color = 'rgb(0,0,255)' # Blue
input_list = [0, 0.5, 1]
- HTML colors:
start_color = '#ff0000' # Red
end_color = '#0000ff' # Blue
input_list = [0, 0.5, 1]
- KML colors:
start_color = 'ff0000ff' # Red
end_color = 'ffff0000' # Blue
input_list = [0, 0.5, 1]
- Scaling input values:
start_color = 'rgb(255,0,0)' # Red
end_color = '#0000ff' # Blue
input_list = [-5, 0, 5, 10] # Values outside 0-1 range
- Jupyter notebook samples:
- See the
notebooksdirectory for more examples
- See the
License
This project is licensed under the terms of the MIT license. See the LICENSE.md file for details.
Code Quality
ruff format src/ tests/
ruff check src/ [--fix]
Tests
pytest --cov
Docs
sphinx-apidoc -o docs/ src/gradpyent
Enjoy the colorful world!
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gradpyent-0.9.3.tar.gz.
File metadata
- Download URL: gradpyent-0.9.3.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3fba45c727721f1ed2f4c5e15213172035cbd89e6a40af7c6bda895c66abd977
|
|
| MD5 |
166639775bbe87e35e4fa7d5e830982f
|
|
| BLAKE2b-256 |
8607a56858cd555ea7544df3da046965a13389dc9e84f1a5835379143bde9216
|
Provenance
The following attestation bundles were made for gradpyent-0.9.3.tar.gz:
Publisher:
publish-to-pypi.yml on lyle-schlueter/gradpyent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gradpyent-0.9.3.tar.gz -
Subject digest:
3fba45c727721f1ed2f4c5e15213172035cbd89e6a40af7c6bda895c66abd977 - Sigstore transparency entry: 211379413
- Sigstore integration time:
-
Permalink:
lyle-schlueter/gradpyent@74d5645cc6d2c4e410f6ba675c516e0b737b8dae -
Branch / Tag:
refs/tags/v0.9.3 - Owner: https://github.com/lyle-schlueter
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@74d5645cc6d2c4e410f6ba675c516e0b737b8dae -
Trigger Event:
push
-
Statement type:
File details
Details for the file gradpyent-0.9.3-py3-none-any.whl.
File metadata
- Download URL: gradpyent-0.9.3-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70c3f80792e12728318d4b23180beb44a6b4a03f4c8ae4d992fb9e7b2b5abd71
|
|
| MD5 |
035198bb7d5441d72268492888a835f9
|
|
| BLAKE2b-256 |
a2761abe44fedfcdcd50e0be00116f74b0e107ece97b5db314ff1d23914d8299
|
Provenance
The following attestation bundles were made for gradpyent-0.9.3-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on lyle-schlueter/gradpyent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gradpyent-0.9.3-py3-none-any.whl -
Subject digest:
70c3f80792e12728318d4b23180beb44a6b4a03f4c8ae4d992fb9e7b2b5abd71 - Sigstore transparency entry: 211379418
- Sigstore integration time:
-
Permalink:
lyle-schlueter/gradpyent@74d5645cc6d2c4e410f6ba675c516e0b737b8dae -
Branch / Tag:
refs/tags/v0.9.3 - Owner: https://github.com/lyle-schlueter
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@74d5645cc6d2c4e410f6ba675c516e0b737b8dae -
Trigger Event:
push
-
Statement type: