symbole_chargement.py

Created by laurent-cortot

Created on February 10, 2020

1.41 KB

serpent carré sur chemin carré


from kandinsky import *
import time

# taille et espacement des carrés
# donnant décallage carré
tailleC = 20
spcC = 5
decC = tailleC + spcC

x = 50
y = 40

L1 = [[x, y], [x + decC, y], [x + 2*decC, y]]
L2 = [[x, y+ decC], [x + decC, y+ decC], [x + 2*decC, y+ decC]]
L3 = [[x, y+ 2*decC], [x + decC, y+ 2*decC], [x + 2*decC, y+ 2*decC]]
grille = [L1, L2, L3]

circuit = [[0,0],[1,0],[2,0],[2,1],[2,2],[1,2],[0,2],[0,1]]

def traceCarre(iCircuit, grille):
  # Actif en noir
  xG, yG = circuit[iCircuit]
  fill_rect(x+xG*decC, y+yG*decC, tailleC, tailleC, color(0,0,0))
  # ancien actif passe en gris
  if iCircuit > 0:
    iCircuit = iCircuit - 1
  else:
    iCircuit = len(iCircuit)
  xG, yG = circuit[iCircuit]
  fill_rect(x+xG*decC, y+yG*decC, tailleC, tailleC, color(100,100,100))
  # ancien gris devient gris clair
  if iCircuit > 0:
    iCircuit = iCircuit - 1
  else:
    iCircuit = len(iCircuit)
  xG, yG = circuit[iCircuit]
  fill_rect(x+xG*decC, y+yG*decC, tailleC, tailleC, color(200,200,200))
  # ancien gris clair devient blanc  
  if iCircuit > 0:
    iCircuit = iCircuit - 1
  else:
    iCircuit = len(iCircuit)
  xG, yG = circuit[iCircuit]
  fill_rect(x+xG*decC, y+yG*decC, tailleC, tailleC, color(255,255,255))


tps = 20
iDebCircuit = 0
while tps > 0:
  traceCarre(iDebCircuit, grille)
  iDebCircuit = (iDebCircuit + 1)%len(circuit)
  tps = tps - 1
  time.sleep(0.001)
  
traceCarre(4, grille)

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