Basic Python Turtle Code: Yin and Yang

Опубликовано: 20 Октябрь 2024
на канале: Basic Python Turtle Art
1,268
13

The traditional symbol of yin and yang generated with arcs and circles.

Feel free to copy and paste the basic Python Turtle code that is given below. Ask questions about the code if you have any. Please enjoy, like, and subscribe! :)

import turtle
t = turtle.Turtle()
screen = turtle.Screen()
t.speed(1)
t.pensize(4)
t.penup()
t.goto(0, -240)
t.pendown()
t.fillcolor("black") #yin the black side starts being drawn here
t.begin_fill()
t.circle(240, 180)
t.left(180)
t.circle(-120,180)
t.circle(120, 180)
t.end_fill()
t.right(180) #yang the white side starts here
t.circle(-240, 180)
t.penup()
t.goto(0, 240/3)
t.pendown()
t.fillcolor("black")
t.begin_fill()
t.circle(240/6)
t.end_fill()
t.penup()
t.goto(0, -2 * 240/3)
t.pendown()
t.fillcolor("white")
t.begin_fill()
t.circle(240/6)
t.end_fill()
t.ht()
screen.exitonclick()