todays color algo
This commit is contained in:
		
							parent
							
								
									ab8ab6f4fe
								
							
						
					
					
						commit
						50603f3a84
					
				
							
								
								
									
										15
									
								
								waves.py
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								waves.py
									
									
									
									
									
								
							| @ -15,11 +15,26 @@ WAVE_OFFSET = 0 - (math.pi/4)#-1.9 | |||||||
| AMPLITUDE = 50 | AMPLITUDE = 50 | ||||||
| # only 1 color with shades? | # only 1 color with shades? | ||||||
| MONOCHROME = True | MONOCHROME = True | ||||||
|  | # works only if monochrome is set - uses todays date as base for the color | ||||||
|  | DATE_BASED_COLOR = True | ||||||
| # background black? White otherwise: | # background black? White otherwise: | ||||||
| DARK_BG = True | DARK_BG = True | ||||||
| # precision of the calculation | # precision of the calculation | ||||||
| PRECISION = 10000 | PRECISION = 10000 | ||||||
| 
 | 
 | ||||||
|  | def todays_color(): | ||||||
|  |     import datetime | ||||||
|  |     import colorsys | ||||||
|  |     import calendar | ||||||
|  |     # a day between 1 and 365 (inclusive) | ||||||
|  |     today = datetime.datetime.now().timetuple().tm_yday | ||||||
|  |     year = datetime.datetime.now().year | ||||||
|  |     days_in_year = 365 + calendar.isleap(year) | ||||||
|  |     # between 0 and 1, how far through the year are we? | ||||||
|  |     progress = today/days_in_year | ||||||
|  |     return colorsys.hsv_to_rgb(progress, 1, 1) | ||||||
|  |      | ||||||
|  | 
 | ||||||
| def main(): | def main(): | ||||||
|      |      | ||||||
|     surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, WIDTH, HEIGHT) |     surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, WIDTH, HEIGHT) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user