decompte.py

Created by schraf

Created on December 29, 2019

1.14 KB

Explications en vidéo ici

31 décembre : Décompte des secondes jusqu’à minuit.

S’il est par exemple 17h29 à votre montre, tapez go(17.30) sur la Numworks et attendez qu’il soit exactement 17h30 sur votre montre pour appuyer sur EXE. Vous aurez alors le décompte des secondes jusqu’à minuit.

Idées de variations : - Affichage plus sophistiqué : Montre Tokyoflash TEN ou STENCIL - Ajout de neige : Exemple ici. Il est possible que la mémoire de votre Numworks ne supporte pas les 200 flocons, dans ce cas diminuez le nombre.


from kandinsky import *
from random import *
from time import *

chiffres = [31599,18724,29671,31207,18925,31183,31695,18727,31727,31215]

def aff(n):
  if n>=0:
    x = 160-24*len(str(n))
    fill_rect(0,80,320,60,(0,0,0))
    # Effet clignotement
    sleep(0.2)
    for k,c in enumerate(str(n)):
      for i in range(16):
        if chiffres[int(c)]>>i & 1 == 1:
          fill_rect(x+48*k+(i%3)*12,80+(i//3)*12,12,12,(255,255,255))
          
def go(hms=21.0000):
  # Exemple 14h05m17s --> 14.0517
  fill_rect(0,0,320,222, (0,0,0))
  h = 23 - int(hms)
  m = 59 - int(100*(hms%1)+.5)
  s = 60 - int(100*(100*hms%1)+.5)
  depart = monotonic()
  t = depart
  total = h*3600 + m*60 + s
  fill_rect(0,160,320,20,(255,255,255))
  while True:
    if monotonic()-t > 1:
      t = monotonic()
      reste = int(total + depart - t)
      if reste >= 0:
        aff(reste)
        fill_rect(0,160,int(320*(total-reste)/total),20,(0,0,0))
      else:
        for i in range(20):
          txt = "BONNE" if random()<.5 else "ANNEE"
          coul = (randint(0,255),randint(0,255),randint(0,255))
          draw_string(txt,randint(-10,320),randint(-10,222),coul)

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>.