1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| import sys, pygame, random
pygame.init()
size = pygame.display.Info()
import os
os.environ['SDL_VIDEO_WINDOW_POS'] = str(size.current_w-70) + "," + str(size.current_h/2-35)
from pygame.locals import *
from time import *
running =True
screen=pygame.display.set_mode((50,70),NOFRAME, 32)
x_scr, y_scr = screen.get_width(),screen.get_height()
class Dot():
def __init__(self, color):
self.color = color
def draw(self,i,u):
pygame.draw.line(screen,color,(6+i*10,9+10*u),(13+i*10,9+10*u),8)
def dec_to_bin(x):
return int(bin(x)[2:])
def fillin(x):
if len(str(x))<6:
x = str((6-len(str(x)))*'0'+ str(x))
return x
else:return str(x)
bin_cursors = []
color1 = [0,200,0]
color2 = [200,0,0]
while running :
cursors = [strftime("%H"), strftime("%M"), strftime("%d"), strftime("%m")]
for i in range(len(cursors)):
bin_cursors.append(fillin(dec_to_bin(int(cursors[i]))))
for event in pygame.event.get():
key_pressed = pygame.key.get_pressed()
if key_pressed[K_ESCAPE]:
pygame.quit()
sys.exit()
mouse_pressed = pygame.mouse.get_pressed()
if mouse_pressed[0]:
mouse_pos = pygame.mouse.get_pos()
if mouse_pos[0]<x_scr/2:
color1 = [random.randint(50,255),random.randint(50,255),random.randint(50,255)]
else: color2 = [random.randint(50,255),random.randint(50,255),random.randint(50,255)]
screen.fill([0,0,0])
for i in range(len(bin_cursors)):
u = 0
while u < len(bin_cursors[i]):
if i < 2:
if bin_cursors[i][u] == "0": color = [color1[0]/10,color1[1]/10,color1[2]/10]
else:color = color1
else :
if bin_cursors[i][u] == "0": color = [color2[0]/10,color2[1]/10,color2[2]/10]
else:color = color2
dot = Dot(color)
dot.draw(i,u)
u+=1
rect = pygame.Rect(2,2,x_scr-5,y_scr-5)
pygame.draw.rect(screen,[30,30,30],rect,2)
pygame.display.update()
bin_cursors = [] |
Partager