python系列之简单太极图

太极大家都知道,如何用python实现呢?
第一步
确立基础数据

#画布大小
setup(1500, 900)
 
#画笔粗细
width(2)
 
#画笔速度
speed(6)

第二步
开始画图

def penud(x,y):
    pu()
    goto(x,y)
    pd()
 
pencolor("black")
 
penud(0,-300)
fillcolor("black")
begin_fill()
circle(300,180)
circle(150,180)
circle(-150,180)
end_fill()
circle(-300,180)
penud(0,100)
fillcolor("white")
begin_fill()
circle(50,360)
end_fill()
penud(0,-200)
fillcolor("black")
begin_fill()
circle(50,360)
end_fill()
ht()
sleep(1000)

最后完整代码呈上

from turtle import *
from time import sleep
 
#画布大小
setup(1500, 900)
 
#画笔粗细
width(2)
 
#画笔速度
speed(6)
 
#更改画笔位置
def penud(x,y):
    pu()
    goto(x,y)
    pd()
 
pencolor("black")
 
penud(0,-300)
fillcolor("black")
begin_fill()
circle(300,180)
circle(150,180)
circle(-150,180)
end_fill()
circle(-300,180)
penud(0,100)
fillcolor("white")
begin_fill()
circle(50,360)
end_fill()
penud(0,-200)
fillcolor("black")
begin_fill()
circle(50,360)
end_fill()
ht()
sleep(1000)

最终效果图
python系列之简单太极图_第1张图片

你可能感兴趣的:(python系列,python,开发语言)