大家好!我是意识流。今天继续跟我学Python。
今天我们用海龟库做一个综合练习,用前面两次学过的知识画一个比较复杂的图形。
要求:
1.画一个立方体
2.用弧线连接立方体的两个对角。
3.以当前位置为起点画一个圆。
4.在花园里画一条S线,感觉像一条阴阳鱼。
5.让线倒着走,盖住前面画的线的一小段。
6.画一条蟒蛇的波浪。
开始编码:
因为代码太长,我就不分段截图了,直接上传文字:
进口甲鱼
Turtle.setup(800,600,200,200)#(屏幕左上角的宽度,高度,坐标x,y)
turtle . bgcolor(& # 34;格雷& # 34;)#背景颜色
Turtle.penup()#提起画笔。
Turtle.fd(-360)#从屏幕中心向左移动360个像素(默认)。
Turtle.pendown()#放下笔
turtle . penzize(30)#书写尺寸
turtle . pen color(& # 34;绿色& # 34;)#钢笔颜色
turtle.fd(400)
turtle . pen color(& # 34;蓝色& # 34;)
乌龟:对(90)
turtle.fd(100)
turtle . pen color(& # 34;紫色& # 34;)
乌龟:对(90)
turtle.fd(400)
turtle . pen color(& # 34;黄色& # 34;)
乌龟:对(90)
turtle.fd(100)
turtle . pen color(& # 34;布朗& # 34;)
乌龟:对(45)
turtle.fd(200)
turtle . pen color(& # 34;红色& # 34;)
乌龟:对(45)
turtle.fd(400)
turtle . pen color(& # 34;蓝色& # 34;)
乌龟大师(下)135
turtle.fd(200)
turtle.penup()
左转弯(45度)
turtle.fd(100)
turtle.pendown()
turtle . pen color(& # 34;黑色& # 34;)
turtle.left(135)
turtle.fd(200)
左转弯(45度)
turtle . pen color(& # 34;粉红& # 34;)
turtle.fd(100)
# -
左转弯(45度)
turtle.circle(330,120)
turtle . pen color(& # 34;蓝色& # 34;)
turtle.circle(230)
turtle . pen color(& # 34;绿色& # 34;)
turtle.circle(180,180)
turtle.colormode(255.0)
turtle.pencolor(255,255,255)
Turtle.circle(90,90)#(半径为正,圆心向左,90度))
turtle.pencolor(180,155,235)
Turtle.circle(-90,90)#(半径为负,圆心在右边,90度)
turtle.pencolor(118,100,35)
Turtle.circle(-90,90)#(圆心在左边,角度为90度,直线沿头部方向画)
turtle.pencolor(125,115,111)
Turtle.circle(-90,-90)#(圆心在右边,角度为-90度,逆着头部方向画直线)
turtle.fd(20)
Turtle.seth(-35)#准备画巨蟒的形状。
# -
对于范围(4)中的I:
turtle.circle(40,80)
乌龟圈(-40,80)
运行它:
看起来眼熟吗?对,这是我第一节课讲龟库的时候展示的图。现在可以完成了,不是很有成就感吗?
好了,今天10分钟的课程到此结束。感谢您参与本次研究!
再见。
最新评论