티스토리 뷰

Test/Python(20220101~)

Days18. Spirograph

kiostory 2022. 2. 20. 16:11
import random
from turtle import Turtle, Screen
import turtle
turtle.colormode(255)
tim = Turtle()
tim.shape("turtle")
tim.pensize(1)
tim.speed("fastest")
def pen_color():
    R = random.randint(0, 255)
    G = random.randint(0, 255)
    B = random.randint(0, 255)
    color = (R,G,B)
    return color
def draw_spirograph(gap):
    heading = 0
    while heading < 360:
        tim.color(pen_color())
        tim.setheading(heading)
        tim.circle(200)
        heading += gap
draw_spirograph(7)
screen = Screen()
screen.exitonclick()

 

'Test > Python(20220101~)' 카테고리의 다른 글

Days19. Make an Etch-a-Sketch  (0) 2022.02.21
Days18. Hirst painting project  (0) 2022.02.20
Days18. 무작위 행보 Turtle  (0) 2022.02.20
Days18. Turtle drawing Polygons  (0) 2022.02.20
Days18. Import module (모듈)  (0) 2022.02.20
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/08   »
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
글 보관함