stencil.py

Created by schraf

Created on July 18, 2019

901 Bytes

Réalisation de la montre suivante sur la NumWorks : https://www.tokyoflash.com/en/watches/kisai-stencil



On peut aussi remplacer le changement des heures - minutes - secondes par :

s+=1
m+=s//60
s%=60
h=(h+m//60)%24
m%=60


Autre présentation

aff(20,20,h//10,3)
aff(80,20,h%10,3)
aff(20,110,m//10,3)
aff(80,110,m%10,3)
aff(180,80,s//10,2)
aff(220,80,s%10,2)


from kandinsky import *
from time import *

# Liste des traits au format x,y,l,h
TR = [[10,1,1,9],[1,10,9,1], \
[10,10,1,1], [11,10,9,1], \
[10,11,1,9], [1,20,9,1], \
[10,20,1,1], [11,20,9,1], \
[10,21,1,9], [0,0,21,1], \
[0,0,1,31], [0,30,21,1], \
[20,0,1,31]]

# Leds utilises pour les differents chiffres 0,1,2...,9
LED = [[4],[0,2,4,6,8], \
[1,7],[1,5],[0,5,6,8], \
[3,5],[3,6],[1,2,4,6,8], \
[2,6],[2,5]]

def aff(x,y,n,z):
  for i,v in enumerate(TR):
    c = [0]*3 if i in LED[n] or i>=9 else [255]*3
    fill_rect(x+z*v[0],y+z*v[1],z*v[2],z*v[3],c)
    
def go(h=12,m=0,s=0):
  while True:
    # On place les elements sur l ecran
    aff(0,0,h//10,4)
    aff(80,30,h%10,4)
    aff(160,60,m//10,4)
    aff(240,90,m%10,4)
    aff(20,140,s//10,2)
    aff(260,10,s%10,2)
    s+=1
    if s>=60:
      s=0
      m+=1
    if m>=60:
      m=0
      h+=1
    if h>=24: h=0
    sleep(1)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.