引言
圣诞节就在眼前,怎样诚挚表达自己的心意呢,自己动手做一个定制动图贺卡,写上定制的祈福语,收到贺卡的人一定很开心。
干货
废话不多说,直接上源代码。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.pendow