第三节 美国队长盾牌
掌握:
- 1.导入turtle 库,起别名;
- 2.画一个圆;
- 3.设置画笔粗细,画笔颜色;
- 4.移动到固定坐标;
- 5.抬笔,落笔;
- 6.隐藏、显示画笔(箭头)
- 7.填充颜色
- 8.画直线,左转、右转
- 9. for 循环
导入库及初始化
# jupyter中导入及初始化
import ipyturtle3 as turtle
from ipyturtle3 import hold_canvas
myCanvas=turtle.Canvas(width=500,height=300) # 创建一个画布
myTS=turtle.TurtleScreen(myCanvas) # 创建一个海龟屏幕,它是海龟绘图的容器
myTS.clear() # 清除屏幕
t=turtle.Turtle(myTS) # 创建一个海龟
display(myCanvas) # 显示画布
# 非jupyter导入库
import turtle
# 导入库,取个别名
import turtle as t
第一步:在中心画出红色的圆圈
t.speed(0)
t.penup()
t.goto(0, -200)
t.pendown()
t.color('red')
t.begin_fill() # 开始填充颜色
t.circle(200)
t.end_fill() # 结果填充颜色
第二步 叠加白色圆(半径缩小)
t.penup()
t.goto(0, -150)
t.pendown()
t.color('white')
t.begin_fill()
t.circle(150)
t.end_fill()
第三步 红色圆圈盖住前两个圆
t.penup()
t.goto(0, -100)
t.pendown()
t.color('red')
t.begin_fill()
t.circle(100)
t.end_fill()
第四步 画蓝色圆盖住前面的图形
t.penup()
t.goto(0, -50)
t.pendown()
t.color('blue')
t.begin_fill()
t.circle(50)
t.end_fill()
第五步 在蓝色圆内画一颗白色的五角星
t.penup()
t.goto(-40, 10)
t.pendown()
t.color('white')
t.begin_fill()
# 补充代码:for循环画一个五角星,边长为80
t.end_fill()
t.hideturtle()
效果如图: