Zmenšujúce sa obdlžniky

import tkinter
canvas = tkinter.Canvas(bg=’white‘, width=1000, height=2000)
canvas.pack()

x0 = 200
y0 = 100
strana01 = 270
strana02 = 150
posun1 = 0
posun2 = 0

farba1, farba2, farba3, farba4 = ‚black‘, ‚green‘, ‚blue‘, ‚red‘
strana1 = strana01
strana2 = strana02
for i in range(8):
canvas.create_rectangle(x0 + posun1, y0 + posun2, x0 + strana01 – posun1, y0 + strana02 – posun2, fill=farba1)
farba1, farba2, farba3, farba4 = farba4, farba1, farba2, farba3
posun1 = posun1 + (1/18) * strana1
strana1 = (8/9) * strana1
posun2 = posun2 + (1/18) * strana2
strana2 = (8/9) * strana2

tkinter.mainloop()

naspäť