【Python】使用turtle库画小马宝莉Rarity

2024-02-29 12:50

本文主要是介绍【Python】使用turtle库画小马宝莉Rarity,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

题目:北京理工大学-Python语言程序设计-Turtle 大作业 :创意设计

要求: 禁止抄袭改编,禁止雷同作品。抄袭作品按零分处理。

先看效果:

b站:动态-哔哩哔哩

再分析思路:

1. 找到喜欢的卡通形象线条图片

2. 使用autoCAD等软件对曲线进行拟合,获取相关数据

3. 对应数据完成python代码

最后给源码:

(由于是我刚学python那会写的,而且距离第一学期的C语言学习已有一年半了,所以代码结构和逻辑非常之烂...看个乐呵吧各位)

import turtle as tdef arc(x0,y0,ang,r,deg):t.goto(x0 - 400, y0 - 200)t.pendown()t.left(ang)t.circle(r,deg)t.penup()t.seth(0)
def len(x0,y0,ang,l):t.goto(x0 - 400,y0 - 200)t.left(90+ang)t.pendown()t.forward(l)t.penup()t.seth(0)wn = t.Screen()
t.colormode(255)
t.hideturtle()
t.speed(20)
t.penup()
t.pensize(1.5)
t.seth(0)#头
t.goto(285.24-400,188.32-200)
t.left(90+2.27)
t.pendown()
t.forward(10.06)
t.penup()
t.seth(0)t.goto(285.64-400,203.88-200)
t.pendown()
t.left(180+57.33)
t.circle(5.78,57.05)
t.penup()
t.seth(0)t.goto(285.64-400,203.88-200)
t.pendown()
t.left(180-122.67)
t.circle(62.28,39.38)
t.penup()
t.seth(0)t.goto(293.12-400,242.70-200)
t.pendown()
t.left(180-134.12)
t.circle(73.09,76.89)
t.penup()
t.seth(0)t.goto(302.25-400,333.13-200)
t.pendown()
t.left(180+33.34)
t.circle(83.43,36.52)
t.penup()
t.seth(0)t.goto(269.77261-400,292.16478-200)
t.pendown()
t.left(180-36.49)
t.circle(45.46,66.1)
t.penup()
t.seth(0)
#角
t.goto(231.84-400,279.67-200)
t.pendown()
t.left(180-52.76)
t.circle(148.09,21.18)
t.penup()
t.seth(0)t.goto(191.85-400,316.61-200)
t.pendown()
t.left(180-25.70)
t.circle(6.01,68.49)
t.penup()
t.seth(0)t.goto(185.16-400,315.6-200)
t.pendown()
t.left(180+64.06)
t.circle(7.88,44.74)
t.penup()
t.seth(0)t.goto(184.78-400,309.61-200)
t.pendown()
t.left(180+113.40)
t.circle(163.7,16.42)
t.penup()
t.seth(0)t.goto(191.46199-400,295.95587-200)
t.pendown()
t.left(180-148.15)
t.circle(23.42,38.91)
t.penup()
t.seth(0)t.goto(201.66-400,279.76-200)
t.pendown()
t.left(180-161)
t.circle(23.78326,49.827344)
t.penup()
t.seth(0)#头
t.goto(200.64561-400,281.13086 -200)
t.pendown()
t.left(180+57.68)
t.circle(73.71936 ,33.500872 )
t.penup()
t.seth(0)t.goto(189.24240 -400,240.19716 -200)
t.pendown()
t.left(180+83.97)
t.circle(30.65330 ,44.147220 )
t.penup()
t.seth(0)t.goto(195.60862 -400,218.05533 -200)
t.left(90+110.52)
t.pendown()
t.forward(6.79738)
t.penup()
t.seth(0)arc(195.61015 ,218.05530 ,180-149.10,25.18947 ,61.750351 )t.goto(199.34311  -400,204.44803  -200)
t.left(52.55)
t.pendown()
t.forward(5.70058)
t.penup()
t.seth(0)arc(201.21959 ,193.34678 ,180-165.03,18.71913 ,45.502409 )t.goto(189.24240 -400,215.67297 -200)
t.pendown()
t.left(180+48.06)
t.circle(8.97477,62.233156 )
t.penup()
t.seth(0)t.goto(187.50102 -400,206.56192 -200)
t.pendown()
t.left(180+110.30)
t.circle(21.90431 ,51.542865 )
t.penup()
t.seth(0)t.goto(201.21806 -400,193.34681 -200)
t.pendown()
t.left(180+154.04)
t.circle(113.04495 ,10.348860 )
t.penup()
t.seth(0)t.goto(220.28212 -400,186.11222 -200)
t.pendown()
t.left(180+178.16)
t.circle(122.12044 ,11.455760 )
t.penup()
t.seth(0)t.goto(244.61364 -400,187.58735 -200)
t.pendown()
t.left(180-169.88)
t.circle(30.84501 ,26.965917 )
t.penup()
t.seth(0)#身体
t.goto(222.48502 -400,164.5556-200)
t.pendown()
t.left(180-134.18)
t.circle(26.79002 ,50.365357 )
t.penup()
t.seth(0)t.goto(216.68276 -400,174.49053 -200)
t.pendown()
t.left(180+120.79)
t.circle(10.47308,56.372931 )
t.penup()
t.seth(0)t.goto(216.68276 -400,174.49053 -200)
t.pendown()
t.left(180-59.21)
t.circle(36.69945 ,97.397649 )
t.penup()
t.seth(0)t.goto(162.46656 -400,184.54690 -200)
t.pendown()
t.left(180+37.24)
t.circle(39.01688 ,28.010484 )
t.penup()
t.seth(0)t.goto(151.20609 -400,169.38626 -200)
t.pendown()
t.left(180+67.40)
t.circle(145.29346 ,22.964500 )
t.penup()
t.seth(0)#右后腿
t.goto(170.23-400,120.23-200)
t.pendown()
t.left(180+55.24)
t.circle(117.72,51.15)
t.penup()
t.seth(0)t.goto(107.55-400,25.49-200)
t.pendown()
t.left(180+154)
t.circle(71.4,36.26)
t.penup()
t.seth(0)t.goto(121.72-400,102.83-200)
t.pendown()
t.left(180+69.59)
t.circle(255.81,18.05)
t.penup()
t.seth(0)t.goto(140-400,118-200)
t.left(90+90+15.37)
t.pendown()
t.circle(28.52,49.86)
t.penup()
t.seth(0)#左后腿
t.goto(194.68-400,108.20-200)
t.left(90+90+71.35)
t.pendown()
t.circle(125.37,37.92)
t.penup()
t.seth(0)t.goto(153.12-400,25.50-200)
t.left(90+90+158.38)
t.pendown()
t.circle(53,46.64)
t.penup()
t.seth(0)t.goto(170.16-400,113.03-200)
t.left(90+90+13.35)
t.pendown()
t.circle(12.08,31.18)
t.penup()
t.seth(0)t.goto(170.23-400,108.20-200)
t.left(90+90-99.23)
t.pendown()
t.circle(13.71,40.55)
t.penup()
t.seth(0)#肚子
t.goto(170.23-400,120.23-200)
t.left(90+90+148)
t.pendown()
t.circle(138.40,19.73)
t.penup()
t.seth(0)#右前腿
t.goto(222.20-400,128.77-200)
t.left(90+90+69.30)
t.pendown()
t.circle(205.96,29.70)
t.penup()
t.seth(0)t.goto(211.44-400,23.73-200)
t.left(90+90+110.52)
t.pendown()
t.circle(11.97,58.61)
t.penup()
t.seth(0)t.goto(220.68-400,16.52-200)
t.left(1.84)
t.pendown()
t.forward(43.64)
t.penup()
t.seth(0)t.goto(244.61-400,122.59-200)
t.left(90+90+83.14)
t.pendown()
t.circle(184.39,34.47)
t.penup()
t.seth(0)#左前腿
t.goto(252.12-400,112.60-200)
t.left(270)
t.pendown()
t.circle(160.14,31.06)
t.penup()
t.seth(0)t.goto(261.48-400,20.727-200)
t.left(18.19)
t.pendown()
t.circle(18.19,52.58)
t.penup()
t.seth(0)t.goto(244.61-400,109.47-200)
t.left(180-162.78)
t.pendown()
t.circle(43.12,32.16)
t.penup()
t.seth(0)#头发前侧#t.fillcolor(147,112,219)
#t.begin_fill()arc(196.56890 ,287.28343 ,180-25.03,55.43891 ,37.807672 )
arc(160.85156 ,291.11508 ,180+12.92,37.32542 ,67.710418 )
arc(133.15455 ,251.40662 ,180+106.96,22.31178 ,39.513146 )
arc(142.17320 ,239.31584 ,180+155.26,303.61631 ,3.462550 )
arc(166.45971 ,205.44000 ,180-125.37,17.86323 ,101.727539 )
arc(143.71075 ,207.91688 ,180+142.93,22.26663 ,61.841198 )
arc(136.63802 ,223.95802 ,180+65.70,11.78560 ,96.269616 )
arc(282.71973 ,315.25892 ,180-46.39,64.32295 ,44.101690 )
arc(239.19292 ,335.76214 ,180-25.52,68.67123 ,20.148386 )
arc(216.03586 ,342.15916 ,180-2.96,79.57092 ,101.120083 )
arc(196.56890 ,273.78911 ,180+20.52,19.31940 ,61.544904 )
arc(184.78527 ,257.91618 ,180+82.13,231.10844 ,6.781631 )
arc(166.45971 ,205.44000 ,180-154.31,28.59089 ,63.219452 )
arc(136.63802 ,223.95802 ,180+165.06,25.16959 ,61.370534 )#t.end_fill()#头发后侧
arc(285.64207 ,188.32415 ,180-145.23,65.83487 ,77.611556 )
arc(285.64207 ,188.32415 ,180+39.82,98.83720 ,28.153322 )
arc(257.31045 ,149.48027 ,67.97+180,10.66232 ,126.371901 )
arc(269.83560 ,135.15105 ,180-173,34.75699 ,82.569925 )
arc(300.35221 ,169.49810 ,180-90.25,12.04322 ,74.671807 )
arc(291.54291 ,181.15113 ,180-11.52,13.00633 ,126.228020 )
arc(277.12919 ,162.97074 ,180+120.62,8.31130 ,153.141863 )
arc(292.57509 ,167.74900 ,180-69.71,6.18779 ,136.722933 )
arc(304.09630 ,162.97074 ,180-113.78,122.06047 ,32.742535 )
arc(267.14100 ,103.92202 ,180-88.07,92.31551 ,22.139890 )
arc(267.14100 ,103.92202 ,270,6.32221 ,97.379463 )
arc(274.24796 ,97.62127 ,180+174,39.19550 ,60.027101 )
arc(310.07568 ,113.55617 ,180-103.08,72.84213 ,45.878097 )
arc(285.64207 ,141.25504 ,180-81.56,51.98897 ,25.926184 )
arc(292.57509 ,167.74900 ,180+110.52,18.05454 ,33.424127 )
arc(284.28168 ,158.89258 ,180-106.71,8.21444 ,72.147118 )#尾巴
arc(191.85019 ,191.78665 ,180-57.22,29.77687 ,57.904149 )
arc(135.99330 ,222.15046 ,180+11.82,59.80071 ,76.291652 )
arc(88.47230 ,165.59017 ,180+70.80,58.55635 ,81.472739 )
arc(57.69999 ,54.93975 ,180+135.36,44.13428 ,71.583866 )
arc(57.69999 ,78.34856 ,180+82.90,94.66220 ,14.204903 )
arc(65.60691 ,89.77097 ,180+20.52,11.28467 ,75.980891 )
arc(76.38363 ,89.77097 ,180-20.34,15.22638 ,41.450020 )
arc(76.49763 ,79.34216 ,180-147.88,6.11557 ,117.012093 )
arc(65.60708 ,82.91206 ,180+111.79,7.07715 ,108.133278 )
arc(162.46656 ,184.54690 ,180-21.75,23.74332 ,85.506694 )
arc(132.39902 ,172.98041 ,180+66.35,54.39006 ,26.541387 )
arc(116.57386 ,214.34550 ,180+62.41,71.95908 ,33.188798 )
arc(108.73520 ,173.99762 ,180+96.07,31.23541 ,61.549160 )
arc(127.90220 ,148.41796 ,180+133.40,44.81670 ,22.550283 )
arc(57.69999 ,78.34856 ,180+136.36,27.45986 ,153.651982 )
arc(65.60708 ,73.07890 ,180-110.81,13.84056 ,41.615047 )
arc(79.12806 ,82.84788 ,180+74.12,20.44384 ,34.00655)##左眼
arc(207.89834 ,240.97979 ,180-32.83,27.66021 ,40.295287 )
arc(194.47226 ,245.35302 ,180+73.02,24.88383 ,59.762353 )
arc(198.97509 ,244.72275 ,180+72.50,34.42185 ,40.026402 )
arc(201.63583 ,243.98266 ,180+56.12,9.94743 ,104.018129 )
arc(195.11233 ,253.29236 ,180+92.56,12.70868 ,43.409546 )
arc(187.50255 ,255.95822 ,180+103.37,21.50639 ,32.903261 )
arc(201.21959 ,224.05840 ,0,3.77536 ,360)##右眼
arc(225.50334 ,237.04974 ,180+74.37,56.36453 ,25.513530 )
arc(229.90873 ,240.19713 ,180-8.58,3.88837 ,88.246613 )
arc(242.59369 ,239.51614 ,180-13.35,35.61833 ,20.544340 )
arc(242.59369 ,239.51614 ,180+171.51,61.53332 ,45.763552 )
arc(233.21379 ,239.77682 ,180+70.22,33.84622 ,51.537207 )
arc(236.28182 ,210.50873 ,180+137.35,10.30991 ,79.542080 )
arc(249.45612 ,209.84651 ,180-171.61,12.36514 ,47.585149 )
arc(264.29188 ,220.12364 ,180+35.58,262.31362 ,1.764423 )
arc(277.93394 ,215.32363 ,180-46.09,16.08731 ,53.420781 )
arc(241.40467 ,239.77682 ,180+69.70,26.77988 ,70.716535 )
arc(261.02502 ,239.55457 ,180+69.04,19.40747 ,61.012226 )
arc(251.68248 ,238.84121 ,180-149.86,28.60701 ,44.322516 )
arc(263.44104 ,239.97514 ,180-136.84,33.92590 ,25.852492 )
arc(272.30865 ,242.40116 ,180-139.43,13.11157 ,33.906667 )
arc(281.85869 ,246.74854 ,180-123.35,14.36831 ,38.583124 )
arc(284.68112 ,230.48516 ,180-55.94,7.96624 ,79.935255 )
arc(254.59052 ,214.14909 ,0,4.95894 ,360)##可爱标记
t.fillcolor(102,178,255)
t.begin_fill()len(176.698 ,179.852 ,28.44,8.116 )
len(172.833 ,186.989 ,144.14,7.365 )
len(168.519 ,181.020 ,-171.16,10.481 )
len(170.048 ,170.651 ,-35.86,11.353 )t.end_fill()t.fillcolor(102,178,255)
t.begin_fill()len(163.33629 ,165.59017 ,23.86,7.06768 )
len(160.47696 ,172.05364,146.12,9.72697 )
len(155.05489 ,163.97805 ,-168.77,8.43685 )
len(156.69767 ,155.70268 ,-33.88,11.90939 )t.end_fill()t.fillcolor(102,178,255)
t.begin_fill()len(168.51865 ,147.76589 ,22.97,8.62030 )
len(165.15458 ,155.70268 ,144.14,11.32599 )
len(158.51989 ,146.52342 ,-164.18,8.55088 )
len(160.85156 ,138.29658 ,-39,12.18409 )t.end_fill()#turtle 逆时针画圆

这篇关于【Python】使用turtle库画小马宝莉Rarity的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/758853

相关文章

python panda库从基础到高级操作分析

《pythonpanda库从基础到高级操作分析》本文介绍了Pandas库的核心功能,包括处理结构化数据的Series和DataFrame数据结构,数据读取、清洗、分组聚合、合并、时间序列分析及大数据... 目录1. Pandas 概述2. 基本操作:数据读取与查看3. 索引操作:精准定位数据4. Group

Python pandas库自学超详细教程

《Pythonpandas库自学超详细教程》文章介绍了Pandas库的基本功能、安装方法及核心操作,涵盖数据导入(CSV/Excel等)、数据结构(Series、DataFrame)、数据清洗、转换... 目录一、什么是Pandas库(1)、Pandas 应用(2)、Pandas 功能(3)、数据结构二、安

Python使用Tenacity一行代码实现自动重试详解

《Python使用Tenacity一行代码实现自动重试详解》tenacity是一个专为Python设计的通用重试库,它的核心理念就是用简单、清晰的方式,为任何可能失败的操作添加重试能力,下面我们就来看... 目录一切始于一个简单的 API 调用Tenacity 入门:一行代码实现优雅重试精细控制:让重试按我

Python安装Pandas库的两种方法

《Python安装Pandas库的两种方法》本文介绍了三种安装PythonPandas库的方法,通过cmd命令行安装并解决版本冲突,手动下载whl文件安装,更换国内镜像源加速下载,最后建议用pipli... 目录方法一:cmd命令行执行pip install pandas方法二:找到pandas下载库,然后

MySQL中EXISTS与IN用法使用与对比分析

《MySQL中EXISTS与IN用法使用与对比分析》在MySQL中,EXISTS和IN都用于子查询中根据另一个查询的结果来过滤主查询的记录,本文将基于工作原理、效率和应用场景进行全面对比... 目录一、基本用法详解1. IN 运算符2. EXISTS 运算符二、EXISTS 与 IN 的选择策略三、性能对比

Python实现网格交易策略的过程

《Python实现网格交易策略的过程》本文讲解Python网格交易策略,利用ccxt获取加密货币数据及backtrader回测,通过设定网格节点,低买高卖获利,适合震荡行情,下面跟我一起看看我们的第一... 网格交易是一种经典的量化交易策略,其核心思想是在价格上下预设多个“网格”,当价格触发特定网格时执行买

Python标准库之数据压缩和存档的应用详解

《Python标准库之数据压缩和存档的应用详解》在数据处理与存储领域,压缩和存档是提升效率的关键技术,Python标准库提供了一套完整的工具链,下面小编就来和大家简单介绍一下吧... 目录一、核心模块架构与设计哲学二、关键模块深度解析1.tarfile:专业级归档工具2.zipfile:跨平台归档首选3.

使用Python构建智能BAT文件生成器的完美解决方案

《使用Python构建智能BAT文件生成器的完美解决方案》这篇文章主要为大家详细介绍了如何使用wxPython构建一个智能的BAT文件生成器,它不仅能够为Python脚本生成启动脚本,还提供了完整的文... 目录引言运行效果图项目背景与需求分析核心需求技术选型核心功能实现1. 数据库设计2. 界面布局设计3

使用IDEA部署Docker应用指南分享

《使用IDEA部署Docker应用指南分享》本文介绍了使用IDEA部署Docker应用的四步流程:创建Dockerfile、配置IDEADocker连接、设置运行调试环境、构建运行镜像,并强调需准备本... 目录一、创建 dockerfile 配置文件二、配置 IDEA 的 Docker 连接三、配置 Do

Android Paging 分页加载库使用实践

《AndroidPaging分页加载库使用实践》AndroidPaging库是Jetpack组件的一部分,它提供了一套完整的解决方案来处理大型数据集的分页加载,本文将深入探讨Paging库... 目录前言一、Paging 库概述二、Paging 3 核心组件1. PagingSource2. Pager3.