Python源码15:使用海龟画图turtle画小黄人

您所在的位置:网站首页 小黄人该怎么画 Python源码15:使用海龟画图turtle画小黄人

Python源码15:使用海龟画图turtle画小黄人

2024-07-12 06:29| 来源: 网络整理| 查看: 265

turtle模块是一个Python的标准库之一,它提供了一个基于Turtle graphics的绘图库。Turtle graphics是一种流行的绘图方式,它通过控制一个小海龟在屏幕上移动来绘制图形。

---------------turtle源码集合---------------

Python教程36:海龟画图turtle写春联

Python源码35:海龟画图turtle画中国结

Python源码31:海龟画图turtle画七道彩虹

Python源码30:海龟画图turtle画紫色的小熊

Python源码29:海龟画图turtle画太极图

Python源码28:海龟画图turtle画熊猫

Python源码27:海龟画图turtle画动态圆舞曲

Python源码26:海龟画图turtle画向日葵

Python源码25:海龟画图turtle画小猪佩奇

Python源码24:使用海龟画图turtle画滑板

Python源码23:使用海龟画图turtle画小狗狗

Python源码22:使用海龟画图turtle画今天日期

Python源码21:使用海龟画图turtle画太阳,云朵,房子,绿树

Python源码20:使用海龟画图turtle画一个会动的星空

Python源码19:海龟画图turtle画螺旋的彩色的逐渐放大的文字

Python源码18:使用海龟画图turtle画捂脸表情

Python源码17:使用海龟画图turtle画五星红旗

Python源码16:使用海龟画图turtle画会动的时钟

Python源码15:使用海龟画图turtle画小黄人

Python源码14:使用海龟画图turtle画我的城堡

Python源码分享13:使用海龟画图turtle画一个会眨眼的皮卡丘

Python源码分享12:使用turtle画彩色六边形

Python源码分享11:使用海龟画图turtle画航天火箭

Python源码分享10:使用海龟画图turtle画哆啦A梦

Python源代码分享:02海龟画图五角星

Python源代码分享:03画一个奥运五环图

Python源代码分享:05使用turtle模块绘制一个彩色螺旋图案

Python源代码分享:07画满天繁星

Python源码分享08:使用turtle画一朵玫瑰花

Python源码分享10:使用海龟画图turtle画哆啦A梦

Python源码分享11:使用海龟画图turtle画航天火箭

Python源码分享12:使用turtle画彩色六边形

# @Author : 小红牛 # 微信公众号:WdPython import turtle as t class DrawYellowpeople(object): #画布初始化 def __init__(self): wn = t.Screen() t.colormode(255) t.hideturtle() t.speed(15)#控制画笔速度 #定位 def Dw(self,x,y): t.penup() t.goto(x,y) t.pendown() #画身体 def mkbody(self): 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() #画眼睛框 def mkclass(self): t.pensize(12) t.penup() t.goto(-100, 200) t.pendown() t.right(100) t.circle(500, 23) t.pensize(3) #画眼睛 def mkeye(self,x,y,z): t.seth(x) t.color("black", "white") t.begin_fill() t.circle(30) t.end_fill() t.penup() t.goto(y, 200) t.pendown() t.color("black", "black") t.begin_fill() t.circle(15) t.end_fill() #点光 t.penup() t.goto(z, 205) t.color("black", "white") t.begin_fill() t.circle(5) t.end_fill() #画嘴巴 def mkmouth(self): t.seth(270) t.color("black", "white") t.begin_fill() t.circle(20, 180) t.left(90) t.forward(40) t.end_fill() #画裤子 def mktrouse(self): 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() #裤腰 def mktrouseby(self,x,y,z,e): t.color("black", "blue") t.begin_fill() t.seth(x) t.forward(15) t.left(y) t.forward(60) t.seth(270) t.forward(15) t.left(z) t.forward(50) t.end_fill() t.left(180) t.goto(e, 30) t.dot() #脚 def mkfoot(self,x,y,z,w,l): t.seth(270) t.color("black", "black") t.begin_fill() t.forward(30) t.left(x) t.forward(40) t.seth(20) t.circle(10, y) t.circle(400, w) t.seth(90) t.forward(l) t.goto(z, -100) t.end_fill() #画手 def mkhands(self,x,y,z): t.seth(x) t.color("black", "yellow") t.begin_fill() t.forward(40) t.left(y) t.forward(z) t.seth(90) t.forward(50) t.end_fill() #画心图案 def mkheart(self): 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() #画口袋 def mkbag(self): 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) #画头发 def mkhair(self,x): t.penup() t.goto(2, 300) t.pendown() t.begin_fill() t.seth(x) t.circle(100, 40) t.end_fill() if __name__ == '__main__': E=DrawYellowpeople() E.mkbody()#身体 E.mkclass()#眼睛框 E.Dw(0,200) E.mkeye(270,15,35)#右眼 E.Dw(0,200) E.mkeye(90,-15,-35)#左眼 E.Dw(-20,100) E.mkmouth() E.Dw(-100,0) E.mktrouse()#裤子 E.Dw(-70,20) E.mktrouseby(45,90,40,-70)#左裤带 E.Dw(70,20) E.mktrouseby(135,-90,-40,70)#右裤带 E.Dw(4,-100) E.Dw(4,-100) E.mkfoot(90,180,4,2,20)#右脚 E.Dw(-4,-100) E.mkfoot(-90,-225,-4,-3,21)#左脚 E.Dw(-100,50) E.mkhands(225,90,35)#右手 E.Dw(100, 50) E.mkhands(315, -90, 36)#左手 E.Dw(0,-100) t.forward(30) E.Dw(0,-20) E.mkheart()#心图案 E.mkbag()#口袋 E.mkhair(135)#左头发 E.mkhair(45)#右头发 t.done()

在这里插入图片描述 完毕!!感谢您的收看

----------★★历史博文集合★★---------- 我的零基础Python教程,Python入门篇 进阶篇 视频教程 Py安装py项目 Python模块 Python爬虫 Json Xpath 正则表达式 Selenium Etree CssGui程序开发 Tkinter Pyqt5 列表元组字典数据可视化 matplotlib 词云图 Pyecharts 海龟画图 Pandas Bug处理 电脑小知识office自动化办公 编程工具 在这里插入图片描述



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3