当前位置: 首页 > news >正文

Python教程56:海龟画图turtle画kitty猫

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

Python教程91:关于海龟画图,Turtle模块需要学习的知识点

Python教程51:海龟画图turtle画(三角形、正方形、五边形、六边形、圆、同心圆、边切圆,五角星,椭圆)

Python源码54:海龟画图turtle画天安门

Python源码53:海龟画图turtle画圣诞树

Python教程52:程序员6款,简易版的爱心表白代码合集

Python源码50:海龟画图turtle画py图标

Python源码49:海龟画图turtle画美国旗

Python教程48:海龟画图turtle画太极八卦阵

Python源码47:海龟画图turtle画巴斯光年

Python源码46:海龟画图turtle画坤坤

Python源码45:海龟画图turtle画雪容融

Python源码44:海龟画图turtle,画2022卡塔尔世界杯吉祥物

Python教程43:海龟画图turtle画小樱魔法阵

Python教程42:海龟画图turtle画海绵宝宝

Python教程41:海龟画图turtle画蜡笔小新

Python教程40:使用turtle画一只杰瑞

Python教程39:使用turtle画美国队长盾牌

Python教程38:使用turtle画动态粒子爱心+文字爱心

Python教程37:使用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 math
import turtle as t
# 爱心
def heart():t.pensize(9)t.setheading(90)t.penup()t.color("deeppink")t.goto(-125, -135)t.pendown()t.begin_fill()t.fillcolor('deeppink')t.circle(9, 211)t.fd(9 * 2.4)t.lt(90)t.fd(9 * 2.4)t.circle(9, 211)t.end_fill()
# 头
def head():t.pensize(8)t.pencolor("black")t.penup()t.goto(-130, 170)t.pendown()t.setheading(220)for x in range(580):t.forward(1)if x < 250:t.left(0.5)elif x < 350:t.left(0.1)else:t.left(0.5)
# 耳朵
def ears():t.setheading(70)for i in range(150):t.forward(1)if i < 80:t.left(0.2)elif i < 90:t.left(10)else:t.left(0.2)t.setheading(160)for i in range(140):t.forward(1)t.left(0.15)t.setheading(140)for i in range(157):t.forward(1)if i < 65:t.left(0.2)elif i < 75:t.left(8)else:t.left(0.5)
# 眼睛
def eyes():# 左眼t.pensize(5)t.penup()t.goto(-100, 60)t.setheading(350)t.pendown()t.fillcolor("black")t.begin_fill()step = 0.3for i in range(2):for j in range(60):if j < 30:step += 0.02else:step -= 0.02t.forward(step)t.left(3)t.end_fill()# 右眼t.penup()t.goto(50, 40)t.setheading(350)t.pendown()t.fillcolor("black")t.begin_fill()step = 0.3for i in range(2):for j in range(60):if j < 30:step += 0.02else:step -= 0.02t.forward(step)t.left(3)t.end_fill()
# 鼻子
def nose():t.penup()t.goto(-40, 30)t.setheading(260)t.pendown()t.fillcolor("#ebc80e")t.begin_fill()step = 0.3for i in range(2):for j in range(60):if j < 30:step += 0.02else:step -= 0.02t.forward(step)t.left(3)t.end_fill()
# 小花
def flower(n):for i in range(n):t.forward(0.5)if i < 80:t.left(1)elif i < 120:t.left(2.3)else:t.left(1)
# 花朵
def flowers():t.penup()t.goto(20, 180)t.pendown()t.fillcolor("#dd4a76")t.begin_fill()t.setheading(175)flower(200)t.setheading(250)flower(200)t.setheading(325)flower(200)t.setheading(40)flower(200)t.setheading(115)flower(170)t.end_fill()t.penup()t.goto(30, 180)t.setheading(270)t.pendown()t.fillcolor("#e7be04")t.begin_fill()t.circle(10)t.end_fill()
# 胡须
def beard():t.penup()t.goto(-150, 65)t.pendown()t.setheading(170)t.pensize(6)for y in range(40):t.forward(1)t.left(0.3)t.penup()t.goto(-150, 85)t.pendown()t.setheading(160)for y in range(50):t.forward(1)t.left(0.3)t.penup()t.goto(-150, 45)t.pendown()t.setheading(180)for y in range(55):t.forward(1)t.left(0.3)t.penup()t.goto(110, 10)t.setheading(340)t.pendown()for y in range(40):t.forward(1)t.right(0.3)t.penup()t.goto(120, 30)t.setheading(350)t.pendown()for y in range(30):t.forward(1)t.right(0.3)t.penup()t.goto(115, 50)t.setheading(360)t.pendown()for y in range(50):t.forward(1)t.right(0.3)
def myarc(t, r, angle):length = 2 * math.pi * r * angle / 360  # angle角度的扇形的弧长n = int(length / 3) + 1  # 线段条数step_length = length / n  # 每条线段的长度step_angle = angle / n  # 每条线段的角度polyline(t, n, step_length, step_angle)
def polyline(t, n, length, angle):for index in range(n):t.fd(length)t.lt(angle)
# 身体
def body():t.pensize(8)t.penup()t.goto(-100, -30)t.setheading(230)t.pendown()t.fillcolor("#efa9c1")t.begin_fill()for z in range(140):t.forward(1)t.left(0.2)t.setheading(340)for z in range(200):t.forward(1)t.left(0.1)t.setheading(85)for z in range(140):t.forward(1)t.left(0.1)t.end_fill()t.penup()t.goto(-73, -33)t.pendown()t.setheading(250)t.fillcolor("#da4b76")t.begin_fill()myarc(t, 40, 205)t.setheading(170)t.pensize(6)t.forward(75)t.end_fill()# 左胳膊t.pensize(8)t.penup()t.goto(-120, -17)t.setheading(230)t.pendown()t.fillcolor("#d64b75")t.begin_fill()t.forward(50)t.setheading(320)for k in range(27):t.forward(1)t.left(1)t.setheading(55)for k in range(50):t.forward(1)t.right(0.1)t.end_fill()# 左手t.penup()t.goto(-125, -15)t.setheading(140)t.pendown()t.fillcolor("pink")t.begin_fill()t.forward(8)t.setheading(50)myarc(t, 10, 190)t.setheading(150)for j in range(80):t.forward(1)t.left(2.2)t.forward(24)t.end_fill()# 右胳膊t.penup()t.goto(27, -45)t.pendown()t.fillcolor("#db4e79")t.setheading(350)t.begin_fill()for x in range(50):t.forward(1)t.right(1)t.setheading(220)t.forward(40)t.setheading(100)for x in range(50):t.forward(1)t.left(0.2)t.end_fill()# 右手t.penup()t.goto(70, -75)t.pendown()t.setheading(300)t.forward(8)t.setheading(30)for x in range(40):t.forward(1)t.right(5)t.setheading(280)for x in range(70):t.forward(1)t.right(2)# 右脚t.penup()t.goto(-70, -180)t.pendown()t.setheading(250)for x in range(30):t.forward(1)t.left(0.3)for x in range(160):t.forward(1)if x < 30:t.left(3)elif x < 65:t.left(0.1)else:t.left(1)# 左脚t.penup()t.goto(-150, -210)t.setheading(340)t.pendown()t.fillcolor("pink")t.begin_fill()step = 1.5for i in range(2):for j in range(60):if j < 30:step += 0.1else:step -= 0.1t.forward(step)t.left(3)t.end_fill()
# 主函数
t.setup(0.8, 0.8)
t.title('hellokitty')
t.bgcolor('pink')
t.hideturtle()t.delay(0)
head()
ears()
eyes()
nose()
beard()
flowers()
body()
heart()
t.penup()
t.goto(300, -100)
t.write('我是一只kitty猫', align='center', font=('楷体', 30, 'normal'))
t.done()

完毕!!感谢您的收看

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

http://www.lryc.cn/news/300077.html

相关文章:

  • c入门第十篇——指针入门
  • pwn学习笔记(3)ret2syscall
  • React18原理: 生命周期中特别注意事项
  • 【C语言】Linux内核bind系统调用代码
  • Ubuntu下Anaconda+PyCharm搭建PyTorch环境
  • 酷开科技荣获“消费者服务之星”称号后的未来展望
  • UVA1449 Dominating Patterns 题解
  • 【C语言】数据结构#实现堆
  • AES加密中的CBC和ECB
  • 【C++】类和对象(四)
  • XGB-5: DART Booster
  • HiveSQL——不使用union all的情况下进行列转行
  • Python环境下基于指数退化模型和LSTM自编码器的轴承剩余寿命预测
  • 无人机竞赛视觉算法开发流程开源计划(询问大家意见)
  • DMA直接内存访问,STM32实现高速数据传输使用配置
  • Web安全研究(六)
  • python3 中try 异常调试 raise 异常抛出
  • Java中的序列化是什么?如何实现对象的序列化和反序列化?请解释Serializable接口的作用是什么?请解释transient关键字的作用是什么?为什么会使用它?
  • 二维差分---三维差分算法笔记
  • D. Divisible Pairs
  • 【教程】Kotlin语言学习笔记(二)——数据类型(持续更新)
  • react 插槽
  • Linux运用fork函数创建进程
  • Pytest测试技巧之Fixture:模块化管理测试数据
  • 设计模式-职责链模式Chain of Responsibility
  • 书生浦语大模型实战营-课程作业(3)
  • 考研英语单词25
  • 计算机网络——08应用层原理
  • 面试计算机网络框架八股文十问十答第五期
  • 拟合案例1:matlab积分函数拟合详细步骤及源码