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)