讲解Python初级课程的turtle模块,简单粗暴的编写了小黄人的程序。程序还需要进一步优化。难点就是要搞清楚turtle在绘制图形过程中的方向变化。

import turtle
t = turtle.Turtle()
wn = turtle.Screen()
turtle.colormode(255)
t.hideturtle()
t.speed(0)
t.penup()
t.pensize(4)
t.goto(100,0)
t.pendown()
t.left(90)
t.color((0,0,0),(255,255,0))
#身体绘制上色
t.begin_fill()
t.forward(200)
t.circle(100,180)
t.forward(200)
t.circle(100,180)
t.end_fill()
#右眼睛绘制上色
t.pensize(12)
t.penup()
t.goto(-100,200)
t.pendown()
t.right(100)
t.circle(500,23)
t.pensize(3)
t.penup()
t.goto(0,200)
t.pendown()
t.seth(270)
t.color("black","white")
t.begin_fill()
t.circle(30)
t.end_fill()
t.penup()
t.goto(15,200)
t.pendown()
t.color("black","black")
t.begin_fill()
t.circle(15)
t.end_fill()
t.penup()
t.goto(35,205)
t.color("black","white")
t.begin_fill()
t.circle(5)
t.end_fill()
#左眼睛绘制上色
t.pensize(3)
t.penup()
t.goto(0,200)
t.pendown()
t.seth(90)
t.color("black","white")
t.begin_fill()
t.circle(30)
t.end_fill()
t.penup()
t.goto(-15,200)
t.pendown()
t.color("black","black")
t.begin_fill()
t.circle(15)
t.end_fill()
t.penup()
t.goto(-35,205)
t.color("black","white")
t.begin_fill()
t.circle(5)
t.end_fill()
#嘴绘制上色
t.penup()
t.goto(-20,100)
t.pendown()
t.seth(270)
t.color("black","white")
t.begin_fill()
t.circle(20,180)
t.left(90)
t.forward(40)
t.end_fill()
#裤子绘制上色
t.penup()
t.goto(-100,0)
t.pendown()
t.seth(0)
t.color("black","blue")
t.begin_fill()
t.forward(20)
t.left(90)
t.forward(40)
t.right(90)
t.forward(160)
t.right(90)
t.forward(40)
t.left(90)
t.forward(20)
t.seth(270)
t.penup()
t.goto(-100,0)
t.circle(100,180)
t.end_fill()
#左裤子腰带
t.penup()
t.goto(-70,20)
t.pendown()
t.color("black","blue")
t.begin_fill()
t.seth(45)
t.forward(15)
t.left(90)
t.forward(60)
t.seth(270)
t.forward(15)
t.left(40)
t.forward(50)
t.end_fill()
t.left(180)
t.goto(-70,30)
t.dot()
#右裤腰带
t.penup()
t.goto(70,20)
t.pendown()
t.color("black","blue")
t.begin_fill()
t.seth(135)
t.forward(15)
t.right(90)
t.forward(60)
t.seth(270)
t.forward(15)
t.right(40)
t.forward(50)
t.end_fill()
t.left(180)
t.goto(70,30)
t.dot()
#脚
t.penup()
t.goto(4,-100)
t.pendown()
t.seth(270)
t.color("black","black")
t.begin_fill()
t.forward(30)
t.left(90)
t.forward(40)
t.seth(20)
t.circle(10,180)
t.circle(400,2)
t.seth(90)
t.forward(20)
t.goto(4,-100)
t.end_fill()
t.penup()
t.goto(-4,-100)
t.pendown()
t.seth(270)
t.color("black","black")
t.begin_fill()
t.forward(30)
t.right(90)
t.forward(40)
t.seth(20)
t.circle(10,-225)
t.circle(400,-3)
t.seth(90)
t.forward(21)
t.goto(-4,-100)
t.end_fill()
#左手
t.penup()
t.goto(-100,50)
t.pendown()
t.seth(225)
t.color("black","yellow")
t.begin_fill()
t.forward(40)
t.left(90)
t.forward(35)
t.seth(90)
t.forward(50)
t.end_fill()
#右手
t.penup()
t.goto(100,50)
t.pendown()
t.seth(315)
t.color("black","yellow")
t.begin_fill()
t.forward(40)
t.right(90)
t.forward(36)
t.seth(90)
t.forward(50)
t.end_fill()
#
t.penup()
t.goto(0,-100)
t.pendown()
t.forward(30)
#
t.penup()
t.goto(0,-20)
t.pendown()
t.color("yellow")
t.begin_fill()
t.seth(45)
t.forward(20)
t.circle(10,180)
t.right(90)
t.circle(10,180)
t.forward(20)
t.end_fill()
#
t.penup()
t.color("black")
t.goto(-100,-20)
t.pendown()
t.circle(30,90)
t.penup()
t.goto(100,-20)
t.pendown()
t.circle(30,-90)
#头顶
t.penup()
t.goto(2,300)
t.pendown()
t.begin_fill()
t.seth(135)
t.circle(100,40)
t.end_fill()
t.penup()
t.goto(2,300)
t.pendown()
t.begin_fill()
t.seth(45)
t.circle(100,40)
t.end_fill()

Python turtle模块小黄人程序的更多相关文章

  1. 微信小程序相关三、css写小黄人

    小程序上课第三天,因为今天院里有活动,所以没去上课,第四天上午又因为要召开入党转正大会,又耽误了一上午,下午去上课,要了资料.这两天讲了一些零零碎碎的东西,做的实例有上面这个小黄人 都是用的css,基 ...

  2. python random模块 - 小驹的专栏 - 博客频道 - CSDN.NET

    python random模块 - 小驹的专栏 - 博客频道 - CSDN.NET python random模块 分类: python 2011-11-15 15:31 6037人阅读 评论(2) ...

  3. 静态分析第三发 so文件分析(小黄人快跑)

    本文作者:i春秋作家——HAI_ 0×00 工具 1.IDA pro 2.Android Killer 0×01 环境 小黄人快跑 下载地址http://download.csdn.net/downl ...

  4. 音频算法之小黄人变声 附完整C代码

    前面提及到<大话音频变声原理 附简单示例代码>与<声音变调算法PitchShift(模拟汤姆猫) 附完整C++算法实现代码> 都稍微讲过变声的原理和具体实现. 大家都知道,算法 ...

  5. css3实现小黄人

    效果就像这样: 不废话,直接上代码! hrml代码: <!DOCTYPE html> <html> <head lang="zh"> <m ...

  6. 纯CSS3画出小黄人并实现动画效果

    前言 前两天我刚发布了一篇CSS3实现小黄人动画的博客,但是实现的CSS3动画是基于我在站酷网找到的一张小黄人的jpg格式图片,并自己用PS抠出需要实现动画的部分,最后才完成的动画效果.但是,其实我的 ...

  7. [置顶] 几行代码实现ofo首页小黄人眼睛加速感应转动

    最新版的ofo 小黄车的首页小黄人眼睛随重力而转动,感觉有点炫酷,学习一下吧,以下代码是在xamarin android下实现 ofo首页效果图: xamarin android实现效果: 实现思路: ...

  8. 小黄人IP营销的四种玩法思维导图

    小黄人IP营销的四种玩法思维导图 ------------------------------ 本人微信公众帐号: 心禅道(xinchandao) 本人微信公众帐号:双色球预测合买(ssqyuce)

  9. CSS3实现小黄人动画

    转载请注明出处,谢谢! 每次看到CSS3动画就心痒痒想试一下,记得一个多月前看了白树哥哥的一篇博客,突然开窍,于是拿他提供的demo试了一下,感觉很棒!下图为demo提供的动画帧设计稿. 自己也想说搞 ...

随机推荐

  1. Maven常用命令汇总

    1.单独构建多模块项目中的某个模块 mvn clean package -pl 模块名 2.跳过测试代码直接打包 mvn install -DskipTests

  2. js回调地域 和 用promise解决方法

    回调地狱: function3({cb3()}){ function2({cb2(cb3)}){ //cb2触发了cb3,并传值 function1({cb1(cb2)}){ //cb1触发了cb2, ...

  3. Spring框架知识整理

    Spring框架主要构成 Spring框架主要有7个模块: 1.Spring AOP:面向切面编程思想,同时也提供了事务管理. 2.Spring ORM:提供了对Hibernate.myBatis的支 ...

  4. 关于Tomcat

    详情转自:http://blog.csdn.net/jiuqiyuliang/article/details/48094373和http://blog.csdn.net/u012934325/arti ...

  5. 指路Reactive Programming

    指路Reactive Programming Mar 02, 2016 in Engineering 我在工作中采用Reactive Programming(RP)已经有一年了,对于这个“新鲜”的辞藻 ...

  6. ansible迭代/迭代嵌套/同步异步/特殊topic说明

    tasks直接举例说明: ---- host: docker  remote_user: root  gather_facts: yes  serial: 3 #表示同一时间控制主机数量(值可以是数值 ...

  7. MD5算法 —— C语言实现(字符串的加密)

    转 https://blog.csdn.net/weixin_42167759/article/details/81209320 网上找到的实现md5函数代码,包括一个头文件md5.h和一个源文件md ...

  8. 实现Map接口(hash原理)

    闲来无事,就实现一个简单的map来练练手吧! HashMap的底层实现主要是基于数组和链表来实现的,HashMap中通过key的hashCode来计算hash值的,由这个hash值计算在数组中的位置, ...

  9. windows查看已连接WIFI密码

    找到wifi图标. 右键,选择打开“网络和internet设置”,选择状态. 选择更改适配器设置. 选择你所连接的WIFI网络. 右键,选择状态. 选择无线属性. 选择安全. 勾选显示字符.

  10. python学习08

    python中的异常处理 1.格式 try 语句块 except else finally else 是如果try语句没有异常,就执行,否则不执行 finally 不管程序是否异常,都会执行. 2.异 ...