Skip to main content

Easily generates a simple linear color array.

Project description

Color Vector

A simple utility that given two colors in RBG format and a number of desired intervals, returns an array of colors evenly distributed between (and including) the two starting colors.

How to use it

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 RBG values that fall on the vector between the starting and ending colors that are equidistant from each other (rounded to the nearest integer).

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.  ```

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

colorvector-0.0.1.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

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

colorvector-0.0.1-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file colorvector-0.0.1.tar.gz.

File metadata

  • Download URL: colorvector-0.0.1.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.2

File hashes

Hashes for colorvector-0.0.1.tar.gz
Algorithm Hash digest
SHA256 2453c99772a954b027140caa38487c416615b9d8b881872449808ddb2a3ff4be
MD5 6e42de787e9dbe219255d84cece79e85
BLAKE2b-256 351f1e6e63582ce1369bde4b9191db9cd183df2ea4bfdbe98bff26d3cb808b4d

See more details on using hashes here.

File details

Details for the file colorvector-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: colorvector-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.2

File hashes

Hashes for colorvector-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 46f8f0b74a412dd70085a5d7beeed6efa60f8f64e259e66d1228ae74c5583bf0
MD5 bf0c828f53a4ed284c65a54ebd03a292
BLAKE2b-256 af2ca5efef2dec7313db54a1787e0d8893b7742693001a6c581541d792435b6e

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