我的编程空间,编程开发者的网络收藏夹
学习永远不晚

Python利用Turtle绘制Technoblade的示例代码

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

Python利用Turtle绘制Technoblade的示例代码

在刚过去不久的6月30日那天,国外一位在YouTube拥有上千万粉丝的我的世界游戏主播Technoblade因癌症与世长辞,年仅23岁,他并没有离开我们,只是用另外一种方式活在了这个世界上。

为了纪念他,特地写了这篇文章,教大家用Turtle绘制出Technoblade,运行效果如下:

代码如下:

首先,用坐标表示每个像素块的颜色,定义一个列表

POS=[
    [4,0,(213,164,9)],
    [6,0,(213,164,9)],
    [9,0,(213,164,9)],
    [11,0,(213,164,9)],
    [4,1,(213,164,9)],
    [5,1,(213,164,9)],
    [7,1,(213,164,9)],
    [9,1,(213,164,9)],
    [11,1,(213,164,9)],
    [6,1,(55,72,160)],
    [8,1,(30,30,154)],
    [8,1,(30,30,154)],
    [10,1,(149,172,2)],
    [4,2,(208,153,8)],
    [5,2,(208,153,8)],
    [6,2,(208,153,8)],
    [7,2,(208,153,8)],
    [8,2,(208,153,8)],
    [9,2,(208,153,8)],
    [10,2,(208,153,8)],
    [11,2,(208,153,8)],
    [4,3,(0,0,0)],
    [5,3,(255,255,255)],
    [6,3,(242,134,132)],
    [7,3,(242,134,132)],
    [8,3,(242,134,132)],
    [9,3,(242,134,132)],
    [10,3,(255,255,255)],
    [11,3,(0,0,0)],
    [4,4,(242,134,132)],
    [5,4,(242,134,132)],
    [6,4,(241,168,162)],
    [7,4,(241,168,162)],
    [8,4,(241,168,162)],
    [9,4,(241,168,162)],
    [10,4,(242,134,132)],
    [11,4,(242,134,132)],
    [4,5,(242,134,132)],
    [5,5,(242,134,132)],
    [6,5,(127,46,43)],
    [7,5,(242,134,132)],
    [8,5,(242,134,132)],
    [9,5,(127,46,43)],
    [10,5,(242,134,132)],
    [11,5,(242,134,132)],
    [4,5,(242,134,132)],
    [5,5,(242,134,132)],
    [6,5,(116,27,29)],
    [7,5,(242,134,132)],
    [8,5,(242,134,132)],
    [9,5,(116,27,29)],
    [10,5,(242,134,132)],
    [11,5,(242,134,132)],
    [4,6,(242,134,132)],
    [5,6,(242,134,132)],
    [6,6,(212,103,108)],
    [7,6,(212,103,108)],
    [8,6,(212,103,108)],
    [9,6,(212,103,108)],
    [10,6,(242,134,132)],
    [11,6,(242,134,132)],
    [4,7,(242,134,132)],
    [5,7,(242,134,132)],
    [6,7,(242,134,132)],
    [7,7,(242,134,132)],
    [8,7,(242,134,132)],
    [9,7,(242,134,132)],
    [10,7,(242,134,132)],
    [11,7,(242,134,132)],
    [0,8,(184,25,38)],
    [1,8,(184,25,38)],
    [2,8,(184,25,38)],
    [3,8,(184,25,38)],
    [0,9,(184,25,38)],
    [1,9,(184,25,38)],
    [2,9,(184,25,38)],
    [3,9,(184,25,38)],
    [0,10,(184,25,38)],
    [1,10,(184,25,38)],
    [2,10,(184,25,38)],
    [3,10,(184,25,38)],
    [0,11,(184,25,38)],
    [1,11,(184,25,38)],
    [2,11,(184,25,38)],
    [3,11,(184,25,38)],
    [0,12,(184,25,38)],
    [1,12,(184,25,38)],
    [2,12,(184,25,38)],
    [3,12,(184,25,38)],
    [0,13,(163,26,36)],
    [1,13,(184,25,38)],
    [2,13,(163,26,36)],
    [3,13,(163,26,36)],
    [0,14,(163,26,36)],
    [1,14,(163,26,36)],
    [2,14,(163,26,36)],
    [3,14,(163,26,36)],
    [0,15,(229,196,187)],
    [1,15,(229,196,187)],
    [2,15,(155,121,112)],
    [3,15,(229,196,187)],
    [0,16,(155,121,112)],
    [1,16,(229,196,187)],
    [2,16,(229,196,187)],
    [3,16,(155,121,112)],
    [0,17,(245,119,126)],
    [1,17,(245,119,126)],
    [2,17,(245,119,126)],
    [3,17,(245,119,126)],
    [0,18,(245,119,126)],
    [1,18,(245,119,126)],
    [2,18,(245,119,126)],
    [3,18,(245,119,126)],
    [0,19,(245,119,126)],
    [1,19,(245,119,126)],
    [2,19,(245,119,126)],
    [3,19,(245,119,126)],
    [4,8,(195,31,48)],
    [4,9,(195,31,48)],
    [4,10,(195,31,48)],
    [4,11,(195,31,48)],
    [4,12,(195,31,48)],
    [4,13,(195,31,48)],
    [4,14,(195,31,48)],
    [5,8,(223,187,178)],
    [5,9,(195,31,48)],
    [5,10,(167,128,123)],
    [5,11,(167,128,123)],
    [5,12,(223,187,178)],
    [5,13,(223,187,178)],
    [5,14,(167,128,123)],
    [6,8,(167,128,123)],
    [6,9,(167,128,123)],
    [6,10,(223,187,178)],
    [6,11,(255,255,255)],
    [6,12,(255,255,255)],
    [6,13,(255,255,255)],
    [6,14,(255,255,255)],
    [7,8,(255,255,255)],
    [7,9,(255,255,255)],
    [7,10,(255,255,255)],
    [7,11,(255,255,255)],
    [7,12,(255,255,255)],
    [7,13,(255,255,255)],
    [7,14,(255,255,255)],
    [8,8,(255,255,255)],
    [8,9,(255,255,255)],
    [8,10,(252,207,4)],
    [8,11,(255,255,255)],
    [8,12,(252,207,4)],
    [8,13,(255,255,255)],
    [8,14,(252,207,4)],
    [9,8,(167,128,123)],
    [9,9,(223,187,178)],
    [9,10,(223,187,178)],
    [9,11,(255,255,255)],
    [9,12,(255,255,255)],
    [9,13,(255,255,255)],
    [9,14,(255,255,255)],
    [10,8,(202,27,44)],
    [10,9,(202,27,44)],
    [10,10,(223,187,178)],
    [10,11,(167,128,123)],
    [10,12,(223,187,178)],
    [10,13,(223,187,178)],
    [10,14,(167,128,123)],
    [11,8,(202,27,44)],
    [11,9,(202,27,44)],
    [11,10,(202,27,44)],
    [11,11,(202,27,44)],
    [11,12,(202,27,44)],
    [11,13,(223,187,178)],
    [11,14,(202,27,44)],
    [12,8,(184,25,38)],
    [13,8,(184,25,38)],
    [14,8,(184,25,38)],
    [15,8,(184,25,38)],
    [12,9,(184,25,38)],
    [13,9,(184,25,38)],
    [14,9,(184,25,38)],
    [15,9,(184,25,38)],
    [12,10,(184,25,38)],
    [13,10,(184,25,38)],
    [14,10,(184,25,38)],
    [15,10,(184,25,38)],
    [12,11,(184,25,38)],
    [13,11,(184,25,38)],
    [14,11,(184,25,38)],
    [15,11,(184,25,38)],
    [12,12,(184,25,38)],
    [13,12,(184,25,38)],
    [14,12,(184,25,38)],
    [15,12,(184,25,38)],
    [12,13,(163,26,36)],
    [13,13,(184,25,38)],
    [14,13,(163,26,36)],
    [15,13,(163,26,36)],
    [12,14,(163,26,36)],
    [13,14,(163,26,36)],
    [14,14,(163,26,36)],
    [15,14,(163,26,36)],
    [12,15,(229,196,187)],
    [13,15,(229,196,187)],
    [14,15,(155,121,112)],
    [15,15,(229,196,187)],
    [12,16,(155,121,112)],
    [13,16,(229,196,187)],
    [14,16,(229,196,187)],
    [15,16,(155,121,112)],
    [12,17,(245,119,126)],
    [13,17,(245,119,126)],
    [14,17,(245,119,126)],
    [15,17,(245,119,126)],
    [12,18,(245,119,126)],
    [13,18,(245,119,126)],
    [14,18,(245,119,126)],
    [15,18,(245,119,126)],
    [12,19,(245,119,126)],
    [13,19,(245,119,126)],
    [14,19,(245,119,126)],
    [15,19,(245,119,126)],
    [4,15,(223,187,178)],
    [5,15,(223,187,178)],
    [6,15,(255,255,255)],
    [7,15,(255,255,255)],
    [8,15,(255,255,255)],
    [9,15,(255,255,255)],
    [10,15,(167,128,123)],
    [11,15,(202,27,44)],
    [4,16,(202,27,44)],
    [5,16,(167,128,123)],
    [6,16,(247,34,56)],
    [7,16,(247,34,56)],
    [8,16,(247,34,56)],
    [9,16,(247,34,56)],
    [10,16,(223,187,178)],
    [11,16,(202,27,44)],
    [4,17,(202,27,44)],
    [5,17,(245,119,126)],
    [6,17,(247,34,56)],
    [7,17,(247,34,56)],
    [8,17,(247,34,56)],
    [9,17,(247,34,56)],
    [10,17,(245,119,126)],
    [11,17,(202,27,44)],
    [4,18,(245,119,126)],
    [5,18,(167,128,123)],
    [6,18,(247,34,56)],
    [7,18,(247,34,56)],
    [8,18,(247,34,56)],
    [9,18,(247,34,56)],
    [10,18,(167,128,123)],
    [4,19,(157,20,30)],
    [5,19,(157,20,30)],
    [6,19,(157,20,30)],
    [7,19,(157,20,30)],
    [8,19,(157,20,30)],
    [9,19,(157,20,30)],
    [10,19,(157,20,30)],
    [11,19,(157,20,30)],
    [4,20,(157,20,30)],
    [5,20,(157,20,30)],
    [6,20,(157,20,30)],
    [7,20,(157,20,30)],
    [8,20,(157,20,30)],
    [9,20,(157,20,30)],
    [10,20,(157,20,30)],
    [11,20,(157,20,30)],
    [4,21,(47,32,29)],
    [5,21,(47,32,29)],
    [6,21,(47,32,29)],
    [7,21,(47,32,29)],
    [8,21,(47,32,29)],
    [9,21,(47,32,29)],
    [10,21,(47,32,29)],
    [11,21,(47,32,29)],
    [4,22,(47,32,29)],
    [5,22,(161,128,119)],
    [6,22,(47,32,29)],
    [7,22,(161,128,119)],
    [8,22,(161,128,119)],
    [9,22,(47,32,29)],
    [10,22,(161,128,119)],
    [11,22,(47,32,29)],
    [4,23,(97,80,73)],
    [5,23,(47,32,29)],
    [6,23,(97,80,73)],
    [7,23,(47,32,29)],
    [8,23,(47,32,29)],
    [9,23,(97,80,73)],
    [10,23,(47,32,29)],
    [11,23,(97,80,73)],
    [4,24,(47,32,29)],
    [5,24,(97,80,73)],
    [6,24,(47,32,29)],
    [7,24,(97,80,73)],
    [8,24,(97,80,73)],
    [9,24,(47,32,29)],
    [10,24,(97,80,73)],
    [11,24,(47,32,29)],
    [4,25,(47,32,29)],
    [5,25,(47,32,29)],
    [6,25,(47,32,29)],
    [7,25,(47,32,29)],
    [8,25,(47,32,29)],
    [9,25,(47,32,29)],
    [10,25,(47,32,29)],
    [11,25,(47,32,29)],
    [4,26,(47,32,29)],
    [5,26,(47,32,29)],
    [6,26,(47,32,29)],
    [7,26,(47,32,29)],
    [8,26,(47,32,29)],
    [9,26,(47,32,29)],
    [10,26,(47,32,29)],
    [11,26,(47,32,29)],
    [4,27,(29,25,24)],
    [5,27,(29,25,24)],
    [6,27,(29,25,24)],
    [7,27,(29,25,24)],
    [8,27,(29,25,24)],
    [9,27,(29,25,24)],
    [10,27,(29,25,24)],
    [11,27,(29,25,24)],
    [4,28,(0,0,0)],
    [5,28,(0,0,0)],
    [6,28,(0,0,0)],
    [7,28,(0,0,0)],
    [8,28,(0,0,0)],
    [9,28,(0,0,0)],
    [10,28,(0,0,0)],
    [11,28,(0,0,0)],
]

我们要的坐标轴是x向右递增,y向下递增,但是y坐标和turtle的坐标轴反了,所以,在遍历并绘制的时候,y坐标这一项要求出相反数

导入Turtle模块,因为我们使用的是rgb,所以要先把colormode设置为255,然后加速,sx和sy表示起始坐标,这个可以自行设定,接下来遍历并绘制即可!最后别忘了隐藏画笔并保持窗口显示!

from turtle import *
 
colormode(255)
speed(0)
 
W=20
sx,sy=-150,250
for x,y,(r,g,b) in POS:
    x2,y2=x*W+sx,(-y)*W+sy
    pu()
    goto(x2,y2)
    pd()
    color((r,g,b))
    begin_fill()
    for i in range(4):
        fd(W)
        right(90)
    end_fill()
 
ht()
done()

到此这篇关于Python利用Turtle绘制Technoblade的示例代码的文章就介绍到这了,更多相关Python Turtle绘制Technoblade内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

Python利用Turtle绘制Technoblade的示例代码

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

Python利用Turtle绘制Technoblade的示例代码

国外一位在YouTube拥有上千万粉丝的我的世界游戏主播Technoblade因癌症与世长辞,为了纪念他,特地写了这篇文章,教大家用Turtle绘制出Technoblade,快跟随小编一起学习一下吧
2023-01-06

Android利用Flutter path绘制粽子的示例代码

目录前言绘制基本轮廓粽叶嘴巴眼睛腮红手&脚头巾咸甜是一家发声动画控制嘴巴开合用到的技术点总结前言 大家好,端午将至,首先提前祝小伙伴端午安康,端午作为中华民族的非常重要的传统节日,粽子那是必不可少的,但是你真的知道粽子的历史吗? 今天跟随本
2022-06-07

Python实现绘制凸包的示例代码

凸包(ConvexHull)是一个计算几何(图形学)中的概念。这篇文章主要为大家详细介绍了Python绘制凸包的示例代码,感兴趣的小伙伴可以了解一下
2023-05-18

利用JavaScript实现绘制2023新年烟花的示例代码

大家过年好!新春佳节,在这个充满喜悦的日子里,愿新年的钟声带给你一份希望和期待。在这喜庆的日子里,小编和大家分享一个烟花代码,希望大家能够喜欢
2023-01-28

编程热搜

  • Python 学习之路 - Python
    一、安装Python34Windows在Python官网(https://www.python.org/downloads/)下载安装包并安装。Python的默认安装路径是:C:\Python34配置环境变量:【右键计算机】--》【属性】-
    Python 学习之路 - Python
  • chatgpt的中文全称是什么
    chatgpt的中文全称是生成型预训练变换模型。ChatGPT是什么ChatGPT是美国人工智能研究实验室OpenAI开发的一种全新聊天机器人模型,它能够通过学习和理解人类的语言来进行对话,还能根据聊天的上下文进行互动,并协助人类完成一系列
    chatgpt的中文全称是什么
  • C/C++中extern函数使用详解
  • C/C++可变参数的使用
    可变参数的使用方法远远不止以下几种,不过在C,C++中使用可变参数时要小心,在使用printf()等函数时传入的参数个数一定不能比前面的格式化字符串中的’%’符号个数少,否则会产生访问越界,运气不好的话还会导致程序崩溃
    C/C++可变参数的使用
  • css样式文件该放在哪里
  • php中数组下标必须是连续的吗
  • Python 3 教程
    Python 3 教程 Python 的 3.0 版本,常被称为 Python 3000,或简称 Py3k。相对于 Python 的早期版本,这是一个较大的升级。为了不带入过多的累赘,Python 3.0 在设计的时候没有考虑向下兼容。 Python
    Python 3 教程
  • Python pip包管理
    一、前言    在Python中, 安装第三方模块是通过 setuptools 这个工具完成的。 Python有两个封装了 setuptools的包管理工具: easy_install  和  pip , 目前官方推荐使用 pip。    
    Python pip包管理
  • ubuntu如何重新编译内核
  • 改善Java代码之慎用java动态编译

目录