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.
Release files for daycolor 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| daycolor-0.0.1.tar.gz | 4.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| daycolor-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:9.4 kB
Release files / daycolor-0.0.1.tar.gz
| Download URL | daycolor-0.0.1.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69edf6f015ddef267ef1f423610acb6662d0f0b6af2e05b2a0ba769c529a3180
|
|
BLAKE2b-256 checksum How to use checksums |
98184104436b509797bcd4b9493fb7e45567e9d17d07c27eaa21ed80153dbcca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / daycolor-0.0.1-py3-none-any.whl
| Download URL | daycolor-0.0.1-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
238b9889ab20cf006cd0e231dfff70c5caeceaf4ae8a492e983f74da2d9d5958
|
|
BLAKE2b-256 checksum How to use checksums |
8dc285b082101ec610e3ddc2e14b828dc66329f9caeb86b2adf21897d8271a9d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|