tiles.py

Created by schraf

Created on March 31, 2024

841 Bytes


from turtle import *
from math import pi
from kandinsky import fill_rect

fill_rect(0, 0, 320, 222, (0, 0, 0))
color("white")
speed(0)

def FillEllipse(x, y, s):
    penup()
    goto(x - 160 + s / 2, y - 110 + s / 6)
    pendown()
    pensize(3)
    circle(s // 3)

def DrawLine(x1, y1, x2, y2):
    penup()
    goto(x1 - 160, y1 - 110)
    pendown()
    pensize(1)
    goto(x2 - 160, y2 - 110)

def DrawTile(x, y, size, n, TxtFreq):
    if n % TxtFreq == 0:
        FillEllipse(x, y, size)
    else:
        DrawLine(x, y, x + size, y + size)
        DrawLine(x, y + size, x + size, y)

def DrawTiles(tileSize, TxtFreq):
    rows = 320 / tileSize
    columns = 222 / tileSize
    for i in range(rows):
        for j in range(columns):
            DrawTile(i * tileSize, j * tileSize, tileSize, i * j, TxtFreq)

DrawTiles(8, 6)

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.