ttt.py

Created by schraf

Created on November 05, 2021

914 Bytes


from math import *
from turtle import *
from kandinsky import fill_rect
from random import randint
from time import sleep

hideturtle()
pensize(2)
speed(9)

def grille():
    for i in range(2):
        fill_rect(75,80 + 60 * i, 180,1,(0,0,0))
        fill_rect(130 + 60 * i,20, 1,180,(0,0,0))

def dessin(c,l,f=1): # col+ligne+figure
 fill_rect(135 + 60 * c, 85 - 60 * l, 50,50,(255,255,255))
 penup()
 color((0,0,0))
 if f == 1: # cercle
    goto(c * 60 + 20, l * 60)
    pendown()
    for k in range(17):
        a = pi * k / 6
        goto(60 * c + 20 * cos(a), 60 * l + 20* sin(a)) 
 else: # croix
    goto(c * 60 - 20, l * 60 - 20)
    pendown()   
    goto(c * 60 + 20, l * 60 + 20)
    penup()
    goto(c * 60 - 20, l * 60 + 20)
    pendown()   
    goto(c * 60 + 20, l * 60 - 20)    

grille()
while True:
    x = randint(-1,1)
    y = randint(-1,1)
    dessin(x,y,randint(0,1))
    #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>.