用python制作贺卡_使用Python创作自己的圣诞节动图贺卡,制作简单即刻生成
引言
圣诞节就在眼前,怎样诚挚表达自己的心意呢,自己动手做一个定制动图贺卡,写上定制的祈福语,收到贺卡的人一定很开心。
干货
废话不多说,直接上源代码。Python 3环境直接运行,无任何依赖。 修改代码中的祝福语字段,就可以定制你自己的动图贺卡了。
# -*- coding: utf-8 -*-
from turtle import *
from random import randint
def create_rectangle(turtle, color, x, y, width, height):
turtle.penup()
turtle.color(color)
turtle.fillcolor(color)
turtle.goto(x, y)
turtle.pendown()
turtle.begin_fill()
turtle.forward(width)
turtle.left(90)
turtle.forward(height)
turtle.left(90)
turtle.forward(width)
turtle.left(90)
turtle.forward(height)
turtle.left(90)
turtle.end_fill()
turtle.setheading(0)
def create_circle(turtle, x, y, radius, color):
oogway.penup()
oogway.color(color)
oogway.fillcolor(color)
oogway.goto(x, y)
oogway.pendown()
oogway.begin_fill()
oogway.circle(radius)
oogway.end_fill()
BG_COLOR = "#0073e6"
oogway = Turtle()
oogway.hideturtle()
oogway.speed(20)
screen = oogway.getscreen()
screen.bgcolor(BG_COLOR)
screen.title("Merry Christmas")
y = -100
create_rectangle(oogway, "#ff6666", -15, y-60, 30, 60)
width = 240
oogway.speed(0)
while width > 10:
width = width - 10
height = 10
x = 0 - width/2
create_rectangle(oogway, "green", x, y, width, height)
y = y + height
oogway.penup()
oogway.color('yellow')
oogway.goto(-20, y+10)
oogway.begin_fill()
oogway.pendown()
for i in range(5):
oogway.forward(40)
oogway.right(144)
oogway.end_fill()
tree_height = y + 40
create_circle(oogway, 230, 180, 60, "white")
create_circle(oogway, 220, 180, 60, BG_COLOR)
number_of_stars = randint(20,30)
for _ in range(0,number_of_stars):
x_star = randint(-(screen.window_width()//2),screen.window_width()//2)
y_star = randint(tree_height, screen.window_height()//2)
size = randint(5,20)
oogway.penup()
oogway.color('white')
oogway.goto(x_star, y_star)
oogway.begin_fill()
oogway.pendown()
for i in range(5):
oogway.forward(size)
oogway.right(144)
oogway.end_fill()
oogway.penup()
# 祝福语
msg = "圣诞快乐!"
oogway.goto(0, -230)
oogway.color("white")
oogway.pendown()
oogway.write(msg, move=False, align="center", font=("Arial", 22, "bold"))
oogway.hideturtle()
screen.mainloop()
欢迎评论交流。
用python制作贺卡_使用Python创作自己的圣诞节动图贺卡,制作简单即刻生成相关推荐
- python 时间序列预测_使用Python进行动手时间序列预测
python 时间序列预测 Time series analysis is the endeavor of extracting meaningful summary and statistical ...
- python 概率分布模型_使用python的概率模型进行公司估值
python 概率分布模型 Note from Towards Data Science's editors: While we allow independent authors to publis ...
- git动图快速制作方法
gif动图快速制作方法(附工具) 现在写博客或是wiki的过程中,会经常引用到图片,特别是客户端经常与页面相关所以截图不可避.但是越来越多的效果仅仅一张图片是无法清楚的描述.并且博客或是wiki也是支 ...
- gif动图怎么制作?手机怎么制作动态图
gif动图怎么制作?手机怎么制作动态图?相信很多朋友都会遇到这样的问题,平时看到许多有趣的gif动图,有的斗图表情包,有的文章配图,都想做一做,但是苦于不知道怎么做,下面我就给大家介绍一种gif制作方 ...
- 网上经常看到的冒泡排序的动图如何制作
今天博主想要和大家分享如何实现动态图,经常在其他博主的文章中可以看到各式各样的动图,搜索一下"网上冒泡排序的动图怎么制作出来"可以看到,很迷,全是告诉冒泡排序的原理,以及动图解析, ...
- gif动图怎么制作?怎么把视频做成gif?
gif动图怎么制作?怎么把视频做成gif呢?我们经常可以看到很多有趣的动态图片,那这些动图gif是怎么做的呢?下面我就给大家介绍一下如果把一段视频做成gif. 首先我们这里需要的是用视频制作成gif, ...
- gif动图怎么制作?视频转gif在线制作方法
gif动图怎么制作?相信很多朋友也经常会有这样的疑问,看到一些很好看的海报动图,以及有趣的表情包,都是gif动图,下面我会告诉大家一种用视频制作gif动图的方法?请往下看. 我个人目前用过比较好用的工 ...
- gif动图在线制作,一分钟教你如何在线gif制作?
大家经常会在日常社交聊天沟通中用到很多的生动有趣.妙趣横生的动图表情包,以体现大家现阶段的情绪或状态下,甚至于有的情况下会和小伙伴们在社交软件上"斗图表情包",而要变为" ...
- python实现动态地图_使用Python、Geopandas和Matplotlib制作gif动态地图
不需要Photoshop:仅使用Python和命令行制作动画图表. 作为一种编程语言,Python非常灵活.这使得有时可以在几行代码中进行大量不同的可视化成为可能.但是现在有了很多不同的图表网站和软件 ...
最新文章
- python实现迭代的快速排序(Iterative Quick Sort)
- 2020年必学的 10 大算法
- mysql修改密码的三种方式
- python 测试 多线程 _thread和threading模块 线程同步,线程优先级队列
- poj3261(求至少出现k次的可重叠的子串的长度)
- html定义一个集合,HTML标签属性集合
- TCP往返时延的估计和超时
- springboot的war和jar包
- HDU 1850 Being a Good Boy in Spring Festival
- Objective-C中的@property和@synthesize用法
- LGBM模型取消打印日志(关闭日志)
- 元气骑士机器人旁边建筑_元气骑士:锤落谁家?锤子更适合机器人还是能双持的骑士呢?...
- 在Windows server 2019 Core 版本上安装SQL2016
- Java项目:在线购书商城系统(java+jsp+mysql+servlert+ajax)
- GBK内码字符串转Unicode字符串
- 基于单片机的便携式瓦斯检测仪系统设计-基于单片机超声波停车位自动检测系统-基于单片机产品数量自动计量系统设计-基于单片机激光电子琴设计-基于单片机锂电池电量显示设计-基于单片机温湿度农田自动灌溉设计
- 简单的Wifi密码破解
- speex java_JAVA版-微信高清语音.speex转.wav格式
- 英语语法成分:主谓宾定状补
- 大学生动物介绍网页设计作品 dreamweaver作业静态HTML网页设计模板 保护动物网页作业制作
热门文章
- 一个Android应届生从上海离职,面试建议
- html5里面的圆点和方块,HTML基础 ul type 项目符号为圆圈与方块
- 网络嵌入算法-Network Embedding-LINE/LANE/M-NMF
- Python中 -m pip install -U --force-reinstall pip 个人经验及解决办法
- mysql数据库巡检方案_Mysql数据库巡检
- Web前端工程师是否真的很难找工作?看这里
- 利用arcgis-ArcMap手动快速检查重庆三调图斑的方法探讨与自动化检查的想法
- 7.博客系统| 评论功能(文章评论,评论的评论)
- OCI指南—OCIStmtExecute()函数
- 主题:分享一个靠谱的免费论文查重网站