Return a interpolated RGB color depending on the time of the day
Project description
daycolor
daycolor allows you to choose a (RGB) colors for multiple times of the day and fluidly return HSV-interpolated "in-between" colors. The times of the day plus the color may be specified in a a daycolordict
as shown below.
This is simply a regular Python dict with strings as indicies. If you need more precision than minutes, you can specify custom patterns.
daycolordict = {
"01:00":(255,127,80),
"02:00":(257,34,35),
"03:00":(126,1,0),
"10:00":(126,255,0),
"11:00":(255,244,66),
"12:00":(253,216,161),
"18:00":(27,25,109),
"19:00":(0,0,254),
"23:00":(255,244,66),
"23:59":(253,261,161)
}
The daycolordict
automagically "wraps around", that means unless desired there will never be a hard jumps between colors.
So for example to get the color for the current time from a dict you could run get_current()
with your dict as an argument:
import daycolor
daycolor.get_current(daycolordict)
If you would rather specify your own time you can do it with the get_by_datetime()
function:
import datetime
# Get the datetime for a hour into the future
a_hour_in_the_future = datetime.datetime.now() + datetime.timedelta(hours=1)
daycolor.get_by_datetime(a_hour_in_the_future, daycolordict)
If you like to interpolate over the colors in a completely different fashion (e.g. randomly selecting a color that is interpolated between the chosen colors) you can do so by using the get_by_value()
function:
import random
value = random.random()
daycolor.get_by_value(value, daycolordict)
Custom Patterns
If you would like to get more accuracy in the timedict you could define your daycolors for example as follows:
daycolordict = {
"00:00.00":(0,0,0),
"00:00.01":(255,0,0),
"00:00.02":(0,0,0),
"00:00.03":(255,0,0),
"00:00.04":(0,0,0),
"00:00.05":(255,0,0),
"00:00.06":(0,0,0),
"00:00.07":(255,0,0),
"00:00.08":(0,0,0),
"00:00.07":(255,0,0),
"00:00.09":(0,0,0),
"12:00.00":(253,216,161),
"23:00.00":(255,244,66),
}
This would return 5 red values every two seconds after midnight and then go black again. To make this wrk you need to call your get_current()
with a pattern like so:
daycolor.get_current(daycolordict, pattern="%H:%M.%S")
If you wanna see how these patterns are defined, check the datetime strftime strptime behavior page. With this you could even achive microsecond precision.
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file daycolor-0.0.1.tar.gz
.
File metadata
- Download URL: daycolor-0.0.1.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.5.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69edf6f015ddef267ef1f423610acb6662d0f0b6af2e05b2a0ba769c529a3180 |
|
MD5 | 3c5ee2ff607ce39542c8a8dcc6837c2b |
|
BLAKE2b-256 | 98184104436b509797bcd4b9493fb7e45567e9d17d07c27eaa21ed80153dbcca |
File details
Details for the file daycolor-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: daycolor-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.5.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 238b9889ab20cf006cd0e231dfff70c5caeceaf4ae8a492e983f74da2d9d5958 |
|
MD5 | 89b6df0a71f058947277c2d5156487d6 |
|
BLAKE2b-256 | 8dc285b082101ec610e3ddc2e14b828dc66329f9caeb86b2adf21897d8271a9d |