栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

用python turtle库画了个紫砂壶

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

用python turtle库画了个紫砂壶

代码如下

#使用turtle库绘制紫砂壶
import turtle as t
t.title('紫砂壶')
t.pensize(2)#画笔宽度
t.pencolor('black')#画笔颜色
t.speed(100)
#t.tracer(0)
t.hideturtle()#隐藏画笔
#画布
#设置画布大小

#画壶盖
t.penup()#提笔
t.goto(-170,100)#去坐标
t.setheading(50)#笔的角度
t.pendown()#落笔
t.circle(-150,100)#画圆,-号代表顺时针,第一个数为半径,第二个数为圆心角

#画半圆
t.penup()
t.goto(-40,158)
t.setheading(40)
t.pendown()
t.circle(10,110)
t.setheading(155)
t.circle(30,50)
t.setheading(210)
t.circle(10,110)

t.penup()
t.goto(-40,158)
t.setheading(310)
t.pendown()
t.forward(8)

t.penup()
t.goto(-68,158)
t.setheading(230)
t.pendown()
t.forward(8)

#画第一条直线
t.penup()
t.goto(-190,100)
t.setheading(0)
t.pendown()
t.forward(270)#画直线
#画第二条线
t.penup()
t.goto(-190,90)
t.setheading(0)
t.pendown()
t.forward(270)
#画第三条直线
t.penup()
t.goto(-190,80)
t.setheading(0)
t.pendown()
t.forward(270)

#画两个半圆
t.penup()
t.goto(-190,100)
t.setheading(180)
t.pendown()
t.circle(5,180)

t.setheading(180)
t.circle(5,180)

t.penup()
t.goto(80,80)
t.setheading(0)
t.pendown()
t.circle(5,180)
t.setheading(0)
t.circle(5,180)



#画壶身
t.penup()
t.goto(-190,80)
t.setheading(220)
t.pendown()
t.circle(100,130)
t.setheading(0)
t.forward(177)
#壶底第二条直线
t.penup()
t.goto(-142,-103)
t.setheading(0)
t.pendown()
t.forward(177)

t.penup()
t.goto(-142,-103)
t.setheading(180)
t.pendown()
t.circle(-4,180)

t.penup()
t.goto(35,-103)
t.setheading(0)
t.pendown()
t.circle(4,180)

#壶身右半圆
t.penup()
t.goto(80,80)
t.setheading(-40)
t.pendown()
t.circle(-100,130)


#画壶把内圈
t.penup()
t.goto(115,20)
t.setheading(90)
t.pendown()
t.circle(-40,40)

t.setheading(50)
t.circle(-30,110)

t.setheading(290)
t.circle(-60,55)

t.setheading(230)
t.circle(-60,10)

t.setheading(210)
t.circle(-50,55)

#画壶把外圈
t.penup()
t.goto(105,-40)
t.setheading(340)
t.pendown()
t.circle(95,48)

t.setheading(42)
t.circle(75,40)

t.setheading(80)
t.circle(80,20)

t.setheading(100)
t.circle(60,15)

t.setheading(124)
t.circle(60,110)

#画壶嘴上半部分
t.penup()
t.goto(-220,40)
t.setheading(146)
t.pendown()
t.forward(70)

t.setheading(180)
t.forward(40)

#画壶嘴下半部分
t.penup()
t.goto(-210,-50)
t.setheading(130)
t.pendown()
t.forward(166)

#画兰草
t.pensize(4)

t.penup()
t.goto(-71,-80)
t.setheading(80)
t.pendown()
t.circle(-200,50)

t.penup()
t.goto(-79,-80)
t.setheading(90)
t.pendown()
t.circle(-200,30)

t.penup()
t.goto(-88,-80)
t.setheading(90)
t.pendown()
t.circle(-240,30)

t.penup()
t.goto(-98,-80)
t.setheading(75)
t.pendown()
t.circle(130,60)

t.penup()
t.goto(-108,-80)
t.setheading(90)
t.pendown()
t.circle(180,55)

#绘图结束画布不消失
t.done()
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/357638.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号