Python绘制灯笼的示例代码

目录
  • 一、效果展示
  • 二、代码展示
  • 三、拓展

一年一度的元宵节刚刚过去,由于时间关系,在元宵节当天晚上11点多才完成本文灯笼的绘制。这两天又在忙着别的事情,所以现在才跟大家分享。

一、效果展示

在介绍代码之前,先来看下本文的实现效果。

视频链接

二、代码展示

接下来展示绘制灯笼的全量源代码

import os
import pygame
import turtle as t 

##画外轮廓
t.title('元宵节字谜灯笼')
t.setup(startx=0, starty = 0)
#画灯笼提线
t.penup()
t.goto(-50, 180)
t.pendown()
t.left(100)
t.pensize(2)
t.color('orangered')
t.circle(-15, 80)
t.right(140)
t.forward(20)
#画灯笼盖
t.penup()
t.goto(-57, 179)
t.pendown()
t.left(120)
t.pensize(1)
#t.pencolor('gold')
t.pencolor('#fedf08')
t.fillcolor('#fedf08')
#t.pencolor('orange')
t.begin_fill()
t.forward(14)
t.right(15)
t.forward(20)
t.right(165)
t.forward(52)
t.goto(-57, 179)
t.end_fill()
t.penup()
t.goto(-78, 174)
t.pendown()
t.left(135)
t.pencolor('#feb209')
t.fillcolor('#feb209')
t.begin_fill()
t.forward(5)
t.left(45)
t.forward(47)
t.goto(-22, 174)
t.end_fill()
#红色的柱子
t.penup()
t.goto(-70, 170)
t.pendown()
t.color('red')
t.begin_fill()
t.right(90)
t.forward(10)
t.left(90)
t.forward(40)
t.left(90)
t.forward(10)
t.end_fill()
def zz(x):
    t.penup()
    t.color('#feb209')
    t.pensize(1)
    t.begin_fill()
    t.goto(x, 160)
    t.forward(10)
    t.right(90)
    t.forward(3)
    t.right(90)
    t.forward(10)
    t.right(90)
    t.forward(3)
    t.end_fill()
    t.right(90)
zz(-64)  #第一根柱子
zz(-55)  #第二根柱子
zz(-45)  #第三根柱子
zz(-37)  #第四根柱子
#棕色的柱子
t.penup()
t.goto(-74, 160)
t.pendown()
t.color('#7f4e1e')
t.left(90)
t.begin_fill()
t.circle(2, 90)
t.forward(5)
t.left(90)
t.forward(52)
t.left(90)
t.forward(5)
t.circle(2, 90)
t.forward(50)
t.end_fill()

#灯笼外壳
t.penup()
t.goto(-76, 153)
t.pendown()
t.begin_fill()
t.color('orangered')
t.circle(30, 90)
t.forward(70)
t.circle(30,90)
t.forward(52)
t.circle(30, 90)
t.forward(70)
t.circle(30, 90)
t.end_fill()
#棕色的柱子
t.penup()
t.goto(-74, 23)
t.pendown()
t.color('#7f4e1e')
#t.left(90)
t.begin_fill()
t.circle(2, 90)
t.forward(5)
t.left(90)
t.forward(52)
t.left(90)
t.forward(5)
t.circle(2, 90)
t.forward(50)
t.end_fill()
#黄色的线
t.penup()
t.goto(-50, 15)
t.pendown()
t.left(90)
t.color('yellow')
t.pensize(1)
t.forward(25)
#玫红色的球
t.right(90)
t.color('red')
t.begin_fill()
t.circle(8, 360)
t.end_fill()
#画流苏
t.penup()
t.goto(-50, -26)
t.pendown()
t.begin_fill()
t.color('orangered')
t.circle(9, 90)
t.forward(80)
t.left(90)
t.forward(18)
t.left(90)
t.forward(80)
t.circle(9, 90)
t.end_fill()
#画流苏中黄色的圈
t.penup()
t.goto(-59, -42)
t.left(90)
t.pendown()
t.begin_fill()
t.color('#fedf08')
t.forward(10)
t.left(90)
t.forward(18)
t.left(90)
t.forward(10)
t.left(90)
t.forward(18)
t.end_fill()

#中文
t.hideturtle()
t.penup()
t.goto(-72, 120)
t.pendown()
t.pencolor('black')
#t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
t.write('猜灯谜', font=('Comic Sans', 11, 'normal'))
t.penup()
t.goto(-87, 91)
t.pendown()
t.pencolor('black')
#t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
t.write('云 盖 中 秋 月', font=('Times New Roman', 10, 'normal'))
t.penup()
t.goto(-87, 65)
t.pendown()
t.pencolor('black')
#t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
t.write('雨 淋 元 宵 灯', font=('Times New Roman', 10, 'normal'))
t.penup()
t.goto(-84, 40)
t.pendown()
t.pencolor('black')
#t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
t.write('(打 一 成 语)', font=('Times New Roman', 10, 'normal'))
t.delay(50)
def write_1():
    #元
    t.penup()
    t.goto(90, 150)
    t.pendown()
    t.pensize(8)
    t.pencolor('red')
    #t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
    t.write('共', font=('Times New Roman', 18, 'normal'))
    #宵
    t.penup()
    t.goto(90, 120)
    t.pendown()
    t.pensize(8)
    t.pencolor('red')
    #t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
    t.write('饮', font=('Times New Roman', 18, 'normal'))
    #节
    t.penup()
    t.goto(90, 90)
    t.pendown()
    t.pensize(8)
    t.pencolor('red')
    #t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
    t.write('太', font=('Times New Roman', 18, 'normal'))
    #快
    t.penup()
    t.goto(90, 60)
    t.pendown()
    t.pensize(8)
    t.pencolor('red')
    #t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
    t.write('平', font=('Times New Roman', 18, 'normal'))
    #乐
    t.penup()
    t.goto(90, 30)
    t.pendown()
    t.pensize(8)
    t.pencolor('red')
    #t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
    t.write('酒', font=('Times New Roman', 18, 'normal'))
def write_2():
    #元
    t.penup()
    t.goto(150, 150)
    t.pendown()
    t.pensize(8)
    t.pencolor('red')
    #t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
    t.write('同', font=('Times New Roman', 18, 'normal'))
    #宵
    t.penup()
    t.goto(150, 120)
    t.pendown()
    t.pensize(8)
    t.pencolor('red')
    #t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
    t.write('猜', font=('Times New Roman', 18, 'normal'))
    #节
    t.penup()
    t.goto(150, 90)
    t.pendown()
    t.pensize(8)
    t.pencolor('red')
    #t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
    t.write('元', font=('Times New Roman', 18, 'normal'))
    #快
    t.penup()
    t.goto(150, 60)
    t.pendown()
    t.pensize(8)
    t.pencolor('red')
    #t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
    t.write('宵', font=('Times New Roman', 18, 'normal'))
    #乐
    t.penup()
    t.goto(150, 30)
    t.pendown()
    t.pensize(8)
    t.pencolor('red')
    #t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
    t.write('谜', font=('Times New Roman', 18, 'normal'))
write_1()
write_1()
write_1()
write_2()
write_2()
write_2()
t.penup()
t.goto(-280, -200)
t.pendown()
t.pensize(8)
t.pencolor('red')
#t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
t.write('Happy Lantern Festival !', font=('Times New Roman', 15, 'normal'))

三、拓展

下面将展示带有背景音乐的绘制灯笼的示例代码,有需要的可以参考一下

import os
import pygame
import turtle as t 

#播放音乐
pygame.mixer.init()
pygame.mixer.music.load(r"F:\公众号\48.元宵节快乐\Sing, R. Sing! - おばちゃ!.mp3")
pygame.mixer.music.set_volume(0.5)
pygame.mixer.music.play()
##画外轮廓
t.title('元宵节字谜灯笼')
t.setup(startx=0, starty = 0)
#画灯笼提线
t.penup()
t.goto(-50, 180)
t.pendown()
t.left(100)
t.pensize(2)
t.color('orangered')
t.circle(-15, 80)
t.right(140)
t.forward(20)
#画灯笼盖
t.penup()
t.goto(-57, 179)
t.pendown()
t.left(120)
t.pensize(1)
#t.pencolor('gold')
t.pencolor('#fedf08')
t.fillcolor('#fedf08')
#t.pencolor('orange')
t.begin_fill()
t.forward(14)
t.right(15)
t.forward(20)
t.right(165)
t.forward(52)
t.goto(-57, 179)
t.end_fill()
t.penup()
t.goto(-78, 174)
t.pendown()
t.left(135)
t.pencolor('#feb209')
t.fillcolor('#feb209')
t.begin_fill()
t.forward(5)
t.left(45)
t.forward(47)
t.goto(-22, 174)
t.end_fill()
#红色的柱子
t.penup()
t.goto(-70, 170)
t.pendown()
t.color('red')
t.begin_fill()
t.right(90)
t.forward(10)
t.left(90)
t.forward(40)
t.left(90)
t.forward(10)
t.end_fill()
def zz(x):
    t.penup()
    t.color('#feb209')
    t.pensize(1)
    t.begin_fill()
    t.goto(x, 160)
    t.forward(10)
    t.right(90)
    t.forward(3)
    t.right(90)
    t.forward(10)
    t.right(90)
    t.forward(3)
    t.end_fill()
    t.right(90)
zz(-64)  #第一根柱子
zz(-55)  #第二根柱子
zz(-45)  #第三根柱子
zz(-37)  #第四根柱子
#棕色的柱子
t.penup()
t.goto(-74, 160)
t.pendown()
t.color('#7f4e1e')
t.left(90)
t.begin_fill()
t.circle(2, 90)
t.forward(5)
t.left(90)
t.forward(52)
t.left(90)
t.forward(5)
t.circle(2, 90)
t.forward(50)
t.end_fill()

#灯笼外壳
t.penup()
t.goto(-76, 153)
t.pendown()
t.begin_fill()
t.color('orangered')
t.circle(30, 90)
t.forward(70)
t.circle(30,90)
t.forward(52)
t.circle(30, 90)
t.forward(70)
t.circle(30, 90)
t.end_fill()
#棕色的柱子
t.penup()
t.goto(-74, 23)
t.pendown()
t.color('#7f4e1e')
#t.left(90)
t.begin_fill()
t.circle(2, 90)
t.forward(5)
t.left(90)
t.forward(52)
t.left(90)
t.forward(5)
t.circle(2, 90)
t.forward(50)
t.end_fill()
#黄色的线
t.penup()
t.goto(-50, 15)
t.pendown()
t.left(90)
t.color('yellow')
t.pensize(1)
t.forward(25)
#玫红色的球
t.right(90)
t.color('red')
t.begin_fill()
t.circle(8, 360)
t.end_fill()
#画流苏
t.penup()
t.goto(-50, -26)
t.pendown()
t.begin_fill()
t.color('orangered')
t.circle(9, 90)
t.forward(80)
t.left(90)
t.forward(18)
t.left(90)
t.forward(80)
t.circle(9, 90)
t.end_fill()
#画流苏中黄色的圈
t.penup()
t.goto(-59, -42)
t.left(90)
t.pendown()
t.begin_fill()
t.color('#fedf08')
t.forward(10)
t.left(90)
t.forward(18)
t.left(90)
t.forward(10)
t.left(90)
t.forward(18)
t.end_fill()

#中文
t.hideturtle()
t.penup()
t.goto(-72, 120)
t.pendown()
t.pencolor('black')
#t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
t.write('猜灯谜', font=('Comic Sans', 11, 'normal'))
t.penup()
t.goto(-87, 91)
t.pendown()
t.pencolor('black')
#t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
t.write('云 盖 中 秋 月', font=('Times New Roman', 10, 'normal'))
t.penup()
t.goto(-87, 65)
t.pendown()
t.pencolor('black')
#t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
t.write('雨 淋 元 宵 灯', font=('Times New Roman', 10, 'normal'))
t.penup()
t.goto(-84, 40)
t.pendown()
t.pencolor('black')
#t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
t.write('(打 一 成 语)', font=('Times New Roman', 10, 'normal'))
t.delay(50)
def write_1():
    #元
    t.penup()
    t.goto(90, 150)
    t.pendown()
    t.pensize(8)
    t.pencolor('red')
    #t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
    t.write('共', font=('Times New Roman', 18, 'normal'))
    #宵
    t.penup()
    t.goto(90, 120)
    t.pendown()
    t.pensize(8)
    t.pencolor('red')
    #t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
    t.write('饮', font=('Times New Roman', 18, 'normal'))
    #节
    t.penup()
    t.goto(90, 90)
    t.pendown()
    t.pensize(8)
    t.pencolor('red')
    #t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
    t.write('太', font=('Times New Roman', 18, 'normal'))
    #快
    t.penup()
    t.goto(90, 60)
    t.pendown()
    t.pensize(8)
    t.pencolor('red')
    #t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
    t.write('平', font=('Times New Roman', 18, 'normal'))
    #乐
    t.penup()
    t.goto(90, 30)
    t.pendown()
    t.pensize(8)
    t.pencolor('red')
    #t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
    t.write('酒', font=('Times New Roman', 18, 'normal'))
def write_2():
    #元
    t.penup()
    t.goto(150, 150)
    t.pendown()
    t.pensize(8)
    t.pencolor('red')
    #t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
    t.write('同', font=('Times New Roman', 18, 'normal'))
    #宵
    t.penup()
    t.goto(150, 120)
    t.pendown()
    t.pensize(8)
    t.pencolor('red')
    #t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
    t.write('猜', font=('Times New Roman', 18, 'normal'))
    #节
    t.penup()
    t.goto(150, 90)
    t.pendown()
    t.pensize(8)
    t.pencolor('red')
    #t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
    t.write('元', font=('Times New Roman', 18, 'normal'))
    #快
    t.penup()
    t.goto(150, 60)
    t.pendown()
    t.pensize(8)
    t.pencolor('red')
    #t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
    t.write('宵', font=('Times New Roman', 18, 'normal'))
    #乐
    t.penup()
    t.goto(150, 30)
    t.pendown()
    t.pensize(8)
    t.pencolor('red')
    #t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
    t.write('谜', font=('Times New Roman', 18, 'normal'))
write_1()
write_1()
write_1()
write_2()
write_2()
write_2()
t.penup()
t.goto(-280, -200)
t.pendown()
t.pensize(8)
t.pencolor('red')
#t.write('猜谜语', font=('Times New Roman', 12, 'normal'))
t.write('Happy Lantern Festival !', font=('Times New Roman', 15, 'normal'))

以上就是Python绘制灯笼的示例代码的详细内容,更多关于Python绘制灯笼的资料请关注我们其它相关文章!

(0)

相关推荐

  • Python制作旋转花灯祝大家元宵节快乐(实例代码)

    目录 1.原材料 1.1 花灯纸 2.2 Python环境和模块 2.源代码 3.效果 1.原材料 1.1 花灯纸 如下所示,还可以加上自己喜欢的图案.文字等. 2.2 Python环境和模块 一台安装了Python环境的电脑,Python环境需要安装以下模块. numpy pillow wxgl 如果没有上述模块,请参考下面的命令安装. pip install numpy pip install pillow pip install wxgl 2.源代码 #元宵节就要到了,花灯要不要来一盏?3

  • 如何基于Python pygame实现动画跑马灯

    前言 大家都看过彩带飘落吧?这个在比较喜庆的场合是很常见的: 还有"跑马灯"效果,听起来很陌生,其实很常见,下面的就是: 好了,相信大家都有了初步的认识.当然,如果有做前端或者搞设计的同学,上面的效果应该不难实现,那如果想通过Python呢?有没有包可以调用呢? 答案是有的--pygame 这个包适合用来开发游戏,今天就不打算给大家详细介绍了,还是想给大伙儿放松放松,以后有机会再多写写它. 不多说,直接甩出代码: import pygame from random import ran

  • 通过Python实现猜灯谜游戏的示例代码

    目录 导语 猜灯谜界面 程序讲解 构造初始界面 构造灯谜类对象 监控鼠标事件 源码 导语 新的一年迎来了元宵节,元宵佳节在陪伴家人的同时,自然也少不了赏花灯,猜灯谜的项目.当然,受到疫情的影响,许多地方今年无法出门赏花灯,猜灯谜. 但是不要紧,小编昨晚用Python弄了一猜灯谜的小程序让大家享受一把猜灯谜乐趣 猜灯谜界面 来看一下猜灯谜的小程序是怎么玩的.先看一下效果图: 程序讲解 构造初始界面 对于程序界面的构造,利用的是python3.6版本下安装2.0.1版本的pygame库.其界面的初始

  • Python+OpenGL制作一个元宵花灯

    目录 1.准备 2.快速体验 3.模型动画 4.子图布局 5.颜色映射 6.走马灯 又是一年元宵节,作为程序员的你,打算怎么过呢?如果昨天情人节的红包发得手软又心疼,不妨静下心来,了解一下三维数据可视化,顺便做一盏花灯送给女朋友,也许比红包更能讨她欢心呢. 1.准备 三维数据快速可视化工具,我喜欢用WxGL.这是一个基于PyOpenGL的三维数据可视化库,提供类似Matplotlib风格的3D绘图函数.如果熟悉NumPy和Matplotlib的话,只需要几分钟时间就可以学会使用WxGL的交互式绘

  • 使用Python制作一盏 3D 花灯喜迎元宵佳节

    说起元宵节,各位有没有觉得这是咱们中国人最浪漫的节日呢?国人向来拘谨古板,一年到头都是小心谨慎地过日子,唯有元宵节这天可以纵情豪放一把.东风夜放花千树,宝马雕车香满路,火树银花霓虹闪烁,豪车遍地美女如云.细品,你甚至都能嗅到香奈儿的味道!月上柳梢头,人约黄昏后,这又是何等的浪漫!比起烛光晚宴.鲜花加持,这份浪漫更显纯真.晚至明清,民间元宵节的喜庆气氛,堪比西班牙的奔牛节.巴西的狂欢节.泰国的泼水节. 由于众所周知的原因,估计今年的趵突泉元宵节灯会又要黄了.去哪儿体验"花市灯如昼"的节日

  • Python+Tkinter制作猜灯谜小游戏

    目录 导语 正文 1)效果展示 2)主程序 导语 元宵节,又称上元节.灯节,是春节之后的第一个重要节日. 相传,汉文帝(前179—前157年)为庆祝周勃于正月十五勘平诸吕之乱,每逢此夜,必出宫游玩,与民同乐,在古代,夜同宵,正月又称元月,汉文帝就将正月十五定为元宵节. 随着社会和时代的变迁,元宵节的风俗习惯在不断变化,但至今仍是中国的传统节日.2008年,元宵节选入第二批国家级非物质文化遗产. 对我而言,除了吃元宵.看花灯……还有一件最重要的事情…就是… 猜灯谜!猜灯谜!!猜灯谜!!!猜谜事小,

  • Python绘制灯笼的示例代码

    目录 一.效果展示 二.代码展示 三.拓展 一年一度的元宵节刚刚过去,由于时间关系,在元宵节当天晚上11点多才完成本文灯笼的绘制.这两天又在忙着别的事情,所以现在才跟大家分享. 一.效果展示 在介绍代码之前,先来看下本文的实现效果. 视频链接 二.代码展示 接下来展示绘制灯笼的全量源代码 import os import pygame import turtle as t ##画外轮廓 t.title('元宵节字谜灯笼') t.setup(startx=0, starty = 0) #画灯笼提线

  • 通过Python绘制中国结的示例代码

    目录 1 中国结的组成部分 2 设计中国结对象 3 绘制结体 4 绘制耳翼 5 绘制挂耳和流苏 6 完整代码,一键运行 1 中国结的组成部分 中国结是一种手工编织工艺品,它身上所显示的情致与智慧正是汉族古老文明中的一个侧面.因为其外观对称精致,可以代表汉族悠久的历史,符合中国传统装饰的习俗和审美观念,故命名为中国结.中国结代表着团结幸福平安,特别是在民间,它精致的做工深受大众的喜爱.其主要组成部分如下图所示. 2 设计中国结对象 基于Python Turtle库实现绘制,首先设计一个中国结对象,

  • Python绘制时钟的示例代码

    目录 导入需要的包设置变量 写数字 绘制时针 完整代码 导入需要的包设置变量 from datetime import datetime from pygame.locals import * import sys, math, pygame def print_text(font, x, y, text, color=(255, 255, 255)): img_text = font.render(text, True, color) screen.blit(img_text, (x, y))

  • python绘制简单折线图代码示例

    1.画最简单的直线图 代码如下: import numpy as np import matplotlib.pyplot as plt x=[0,1] y=[0,1] plt.figure() plt.plot(x,y) plt.savefig("easyplot.jpg") 结果如下: 代码解释: #x轴,y轴 x=[0,1] y=[0,1] #创建绘图对象 plt.figure() #在当前绘图对象进行绘图(两个参数是x,y轴的数据) plt.plot(x,y) #保存图象 plt

  • Python+Turtle绘制幸运草的示例代码

    目录 一.效果展示 二.代码详解 1.导入库 2.播放音乐 3.定义画四叶草的函数 4.调用函数绘制四叶草 5.设置写文字的函数 幸运草又名四叶草,一般指四叶的苜蓿.或车轴草. 在十万株苜蓿草中,你可能只会发现一株是四叶草,机会率大约是十万分之一. 因此四叶草是国际公认的幸运象征. 本文主要介绍运用turtle库控制函数绘制四叶草,希望见者皆好运,祝福大家的生活都能幸福安康. 一.效果展示 在介绍代码之前,先来看下本文的实现效果. 可以把视频中的名字替换成你所想的名字,并参考下面步骤把Pytho

  • Python+Turtle绘制蜘蛛侠的示例代码

    目录 一.效果展示 二.代码详解 1.导入库 2.播放音乐 3.定义画蜘蛛侠上半身的函数 4.定义画左手和右手的函数 5.定义画蜘蛛的函数 6.调用函数绘制图形 蜘蛛侠(Spider-Man)即彼得·帕克(Peter Parker),是美国漫威漫画旗下超级英雄. 由编剧斯坦·李和画家史蒂夫·迪特科联合创造,初次登场于<惊奇幻想>(Amazing Fantasy)第15期(1962年8月). 因为广受欢迎,几个月后,便开始拥有以自己为主角的单行本漫画. 网易云中关于蜘蛛侠主题曲热评过万的评论说到

  • Python+turtle绘制对称图形的示例代码

    目录 1.图1 2.图2 3.图3 4.图4 5.图5 6.图6 最近有个朋友,想要我帮忙用python画几个图,在画的过程中觉得有些图还挺有意思的,分享给大家. 1.图1 第一个图是由三角形组成的花,感兴趣的小伙伴可以自己尝试在python中用turtle库绘制一下. 具体代码如下: # -*- coding: UTF-8 -*- ''' 代码用途 :画对称图形 作者 :阿黎逸阳 博客 : https://blog.csdn.net/qq_32532663/article/details/10

  • 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,16

  • python 绘制国旗的示例

    国旗是一个国家的象征,它可以反映一个国家的特色和传统,国旗起源于近代的欧洲,是一个国家主权意识不断增强后的必然产物,本文我们使用 Python 来画几面国旗,使用的 Python 库是大家比较熟悉的 turtle. 五星红旗 五星红旗是中华人民共和国的国旗,它是由四颗小的黄五角星环绕一颗大的黄五角星组成的,底色为红色,实现代码如下: turtle.setup(600,400,0,0) turtle.bgcolor("red") turtle.fillcolor("yellow

  • Python实现区域填充的示例代码

    所用的库及环境: IDE:Pycharm Python环境:python3.7 Matplotlib: Matplotlib 1.11 Numpy: Numpy1.15. 区域填充 前言 如何填充一块区域,就是给一块区域上色 代码及效果图 fill()函数介绍 文档:https://matplotlib.org/api/_as_gen/matplotlib.pyplot.fill.html 介绍:绘制填充多边形 属性: args:是一个x,y的序列,每个多边形由其节点x和y的位置列表定义 col

随机推荐