操纵海龟绘图有着许多的命令,这些命令可以划分为两种:一种为运动命令,一种为画笔控制命令

1. 运动命令:

forward(degree)  #向前移动距离degree代表距离

backward(degree) #向后移动距离degree代表距离

right(degree)    #向右移动多少度

left(degree)      #向左移动多少度

goto(x,y)           #将画笔移动到坐标为x,y的位置

stamp()           #复制当前图形

speed(speed)     #画笔绘制的速度范围[0,10]整数

2. 画笔控制命令:

down() #移动时绘制图形,缺省时也为绘制

up()      #移动时不绘制图形

pensize(width)     #绘制图形时的宽度

color(colorstring) #绘制图形时的颜色

fillcolor(colorstring) #绘制图形的填充颜色

#编码步骤:

第一步:先画出一个五角星

for i in range():
turtle.forward()
turtle.right()

第二步:将画笔起始位置移到坐标(-200,0)的位置上,移动的时候不可以绘制,需要用到turtle.up()的方法

turtle.up()     #移动时不绘制图形
turtle.goto(x,) #将画笔移动到坐标为(x,0)的位置

第三部:移动到目标坐标后,需要使画笔重新可以绘制,需要用到turtle.down()方法

turtle.down() #移动时绘制图形,缺省时也为绘制

完整代码:

import turtle

x = -200        #画笔位置的横坐标
fw = 100 #移动的距离
r = 144 #移动的方向 turtle.pensize(4) #设置画笔宽度
turtle.up() #移动时不绘制图形
turtle.goto(x,0) #将画笔移动到坐标为(-200,0)的位置
turtle.pencolor("red")
turtle.down() #移动时绘制图形,缺省时也为绘制
for i in range(5):
turtle.forward(fw)
turtle.right(r) turtle.goto(x+100,0)
turtle.pencolor("blue")
for i in range(5):
turtle.forward(fw)
turtle.right(r) turtle.goto(x+200,0)
turtle.pencolor("black")
for i in range(5):
turtle.forward(fw)
turtle.right(r) turtle.goto(x+300,0)
turtle.pencolor("blue")
for i in range(5):
turtle.forward(fw)
turtle.right(r) turtle.goto(x+400,0)
turtle.pencolor("red")
for i in range(5):
turtle.forward(fw)
turtle.right(r)

最新文章

  1. oracle is not in the sudoers file. This incident will be reported.
  2. GConf error:Failed to contact configuration server
  3. SQL技巧
  4. C# Base64字符串转换成图片及图片转换为Base64
  5. HTML&CSS基础学习笔记1.14—有序列表及列表嵌套
  6. 在Linux手动把文件转码的方法,防止乱码出现
  7. 【翻译自mos文章】回收 asm磁盘空间的方法
  8. oracle_彻底删除oracle
  9. 老李分享:为何要使用 Web Services
  10. SQLServer之创建不可重复读
  11. Win 7 家庭普通版系统升级密钥
  12. node 跨域问题
  13. 浅析Java源码之HashMap外传-红黑树Treenode(已鸽)
  14. linux-nohup后台运行
  15. What is Gensim?
  16. (线段树)敌兵布阵--hdu--1166 (入门)
  17. datagrid在MVC中的运用10-勾选
  18. 【重要】新浪微博api研究
  19. Tinkoff Challenge - Elimination Round B. Igor and his way to work(dfs+优化)
  20. PHP中的=>,->,@,&,::,%

热门文章

  1. JAVA POI XSSFWorkbook导出扩展名为xlsx的Excel,附带weblogic 项目导出Excel文件错误的解决方案
  2. FHS 文件层次标准
  3. 解决asp.net web api时间datetime自动带上带上的T和毫秒的问题
  4. 2018-8-10-如何删除错误提交的-git-大文件
  5. JS规则 我与你同在(逻辑与操作符)数学中的“b大于a,b小于c”是“a<b<c”,那么在JavaScript中可以用&&表示
  6. 提问(prompt 消息对话框)用于询问一些需要与用户交互的信息。弹出消息对话框(包含一个确定按钮、取消按钮与一个文本输入框)
  7. artTemplate不仅可以在浏览器中使用,还可以在node中使用
  8. loj6247 九个太阳
  9. Miler-Rabbin素数判定
  10. JOIN方法也是连贯操作方法之一