python学习笔记9--用turtle简单绘图2

这篇博客介绍了Python turtle模块中的一些高级绘图函数,包括设置线条粗细、调整绘制速度、图形填充、圆形内多边形绘制、文本写入、箭头隐藏等。通过实例演示了这些函数的使用方法,帮助读者深入理解turtle库的更多功能。
摘要由CSDN通过智能技术生成

前面写了一篇用turtle简单绘图,这一节再多学习几个turtle的函数,函数都比较简单,一看就明白的。首先贴一个小程序和运行结果,然后对其中用到的新函数做简单解释。

# draw various shapes
import turtle

turtle.showturtle()

turtle.pensize(3)          # 1)
turtle.speed(10)           # 2)

# draw polygon with 3 sides and fill with red
turtle.penup() 
turtle.goto(-200,0)
turtle.pendown()
turtle.begin_fill()       # 3)
turtle.color("red") 
turtle.circle(50,steps=3) # 4)
turtle.end_fill()         # 5)

# draw polygon with 5 sides and fill with green
turtle.penup()
turtle.goto(0,0)
turtle.pendown()
turtle.begin_fill()
turtle.color("green")
turtle.circle(50,steps=5)
turtle.end_fill()

# draw a polygon with 7 sides and fill with purple
turtle.penup()
turtle.goto(200,0)
turtle.pendown()
turtle.begin_fill()
turtle.color("purple")
turtle.circle(50,steps=7)
turtle.end_fill()

turtle.color("green")
turtle.penup()
turtle.goto(-25,100)
turtle.pendown()
turtle
  • 1
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值