colors.py

Created by stimorol

Created on June 30, 2023

1.8 KB

Programme déposant aléatoirement des pixels de couleurs différentes. Des combinaisons de couleur sont proposées, et l’utilisateur peut créer les siennes. Appuyez simplement sur les nombres à coté des options proposées pour choisir !


from math import *
from ion import *
from kandinsky import *
from turtle import *
from time import *
from random import *

keys1=[KEY_ZERO, KEY_ONE, KEY_TWO, KEY_THREE]
keys=[KEY_DOT, KEY_EE, KEY_ONE, KEY_TWO, KEY_THREE, KEY_FOUR, KEY_FIVE, KEY_SIX, KEY_SEVEN, KEY_EIGHT, KEY_NINE]
spetial=['gray','purple','orange','pink','white','black','brown','yellow','red','blue','green']
selectedColors=[]
stop=False

def draw(list):
  reset()
  for i in range(100000):
    set_pixel(randint(0,320),randint(0,222),choice(list))
  draw_string("stop",0,0)
  
def colors():
  hideturtle()
  reset()
  stop=False
  draw_string("1: Black & White\n       2: Red, Blue & Green\n       3: All\n       0: Choice",70,80)
  while not stop:
    for i in keys1:
      if keydown(i):
        while keydown(i):
          pass
        menu=(keys1.index(i))
        stop=True  
  if menu == 1:
    draw(['black','black','white'])
  elif menu == 2:
    draw(['red','blue','green'])
  elif menu == 3:
    draw(['gray','purple','orange','pink','white','black','brown','yellow','red','blue','green'])
  elif menu == 0:
    reset()
    draw_string("            0: random\n          dot: gray\n           EE: purple\n            1: orange\n            2: pink\n            3: white\n            4: black\n            5: brown\n            6: yellow\n            7: red\n            8: blue\n            9: green",0,0)
    stop=False
    sleep(0.1)
    while not stop:
      for i in keys:
        if keydown(i):
          while keydown(i):
            pass
          selectedColors.append(spetial[keys.index(i)])
      if keydown(KEY_EXE):
        reset()
        hideturtle()
        while keydown(KEY_EXE):
          pass
        for i in range(100000):
          set_pixel(randint(0,320),randint(0,222),choice(selectedColors))
      else:
         pass
colors()

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.