-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpavucina.py
More file actions
32 lines (25 loc) · 775 Bytes
/
pavucina.py
File metadata and controls
32 lines (25 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# barevná (random) pavučina pomocí knihovny turtle
import turtle
from turtle import bgcolor, exitonclick, title
from random import randrange
import tkinter
title("Spider Web")
img = tkinter.Image("photo", file="turtle_ico.png")
turtle._Screen._root.iconphoto(True, img)
# Vytvoříme novou želvu
t = turtle.Turtle()
bgcolor("black")
t.pensize(3)
t.speed(10)
# uzel se skládá ze 3 smyček
for uzel in range (100):
# smyčka uzlu se skládá ze 4 hran
for smycka in range (3):
# pro každý uzel je náhodně vygenerována barva
t.pencolor(randrange(0,10)/10, randrange(0,10)/10, randrange(0,10)/10)
for hrana in range (4):
t.forward(20)
t.left(90)
t.left(20)
t.forward(20 + 5*uzel)
exitonclick()