Color Vector
A simple utility that given two colors in RGB format and a number of desired intervals, returns an array of colors evenly distributed between (and including) the two starting colors.
Installation
pip install colorvector
How to use it
from colorvector import get_palette
palette = get_palette([0, 0, 0], [255, 255, 255], 3)
print(palette)
# [(0, 0, 0), (128, 128, 128), (255, 255, 255)]
Import the get_palette function and feed it your starting and ending colors as arrays of three integers (e.g. [0, 0, 0] and [255, 255, 255]) and an integer representing the number of colors you want in the palette (includes the two colors you gave it).
It will return an array of RGB values that fall on the vector between the starting and ending colors that are equidistant from each other (rounded to the nearest integer).
Input rules:
- Colors must have exactly 3 integer values from 0 to 255.
nmust be an integer greater than or equal to 2.
So, if you give it: [0, 0, 0], [255, 255, 255], 3
It will return: [(0, 0, 0), (128, 128, 128), (255, 255, 255)]
How the math works:
To lay out the points from Point 1 to Point 2,
Subtract (5,0,-1) - (1,2,3) to get the direction vector for the line. In this case, <4, -2, -4>.
Then create the parametric equation for the line <x,y,z> = t * <4, -2, -4> + <1,2,3>
This set up leads to:
when t = 0, <x,y,z> = 0* <4, -2, -4> + <1,2,3> = < 1,2,3 >
when t = 1, <x,y,z> = 1* <4, -2, -4> + <1,2,3> = < 5,0,-1 >
To distribute points evenly along this interval, distribute t evenly at the fractional size you need.
For example for 6 points between and including both Point 1 and Point 2, divide into 5ths by letting
t=0, .2, .4, .6, .8, 1. ```
Metadata
Release files for colorvector 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| colorvector-0.0.2.tar.gz | 4.2 kB | Without provenance | Details for colorvector-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| colorvector-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for colorvector-0.0.2-py3-none-any.whl |
Total release size: 8.3 kB
Release files / colorvector-0.0.2.tar.gz
| Download URL | colorvector-0.0.2.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7305cc7f7a7995ea166bd1449af5321917483eef0bd94ff3fdc22c898f381c99
|
|
BLAKE2b-256 checksum How to use checksums |
7f536966aa8ad4db2a8c0ab502f30e5d3848cff05d01dc88dcd92aa76988979c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / colorvector-0.0.2-py3-none-any.whl
| Download URL | colorvector-0.0.2-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3219ee45d5c28d21b65555833c424bc386dd4439fa7e207d91c23149a3437f9d
|
|
BLAKE2b-256 checksum How to use checksums |
e5b387fefddaaec7aee8a5fbbc5c7be354112e5e1aea9959613eba4f7bdd88e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Security for colorvector 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.