Skip to main content

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 notebooks directory for more examples

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

gradpyent-0.9.5.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

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

gradpyent-0.9.5-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file gradpyent-0.9.5.tar.gz.

File metadata

  • Download URL: gradpyent-0.9.5.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

Hashes for gradpyent-0.9.5.tar.gz
Algorithm Hash digest
SHA256 e47764b8caea168b4bbd69749058db2d28e44dad11230bfaaca7d129e0ec6ee6
MD5 edcedda507e05799f8f7efd15eaaaba9
BLAKE2b-256 4d9afb9af8a14ad395b0aa72fb7e5787ea5fdc1ca6681bc234a365d0e468b8f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for gradpyent-0.9.5.tar.gz:

Publisher: publish-to-pypi.yml on lyle-schlueter/gradpyent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gradpyent-0.9.5-py3-none-any.whl.

File metadata

  • Download URL: gradpyent-0.9.5-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for gradpyent-0.9.5-py3-none-any.whl
Algorithm Hash digest
SHA256 eef3adc835c0af507db6de4c719e3e27aae7dcd9c66826be81e592cff601e02d
MD5 07ab2e5594939a08f3b443614c4216fe
BLAKE2b-256 3eb4dbc72000b7316bde2074ff162dd8d559ef2fb1ace4cac008af243b581601

See more details on using hashes here.

Provenance

The following attestation bundles were made for gradpyent-0.9.5-py3-none-any.whl:

Publisher: publish-to-pypi.yml on lyle-schlueter/gradpyent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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