今天是圣诞节,送你一棵圣诞树,圣诞节快乐!!

源代码领取↓(直接复制粘贴即可)

# -*- 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()

圣诞节快乐!!!٩(๑^o^๑)۶

python话圣诞树_python画圣诞树相关推荐

  1. python画圣诞树_python画圣诞树

    使用python画一棵圣诞树 height = 5stars = 1for i in range(height): print((' ' * (height - i)) + ('*' * stars) ...

  2. 使用python的turtle库函数画圣诞树详细教程

    今天改bug改到自闭,花了一晚上时间最后发现是一个小参数导致的,唉! 想到最近画圣诞树不是很火嘛,就放松一下,出个画圣诞树的教程吧. 首先我们的目标是这样子的: 那么他有什么成分呢?有圣诞树的本体.大 ...

  3. python樱花卡片_Python画一棵漂亮的樱花树(不一样种樱花+玫瑰+圣诞树喔)

    很多用Python(大可能是turtle库)绘制的树图,感受很漂亮,我整理了一下,挑了一些我以为不错的代码分享给你们(这些我都测试过,确实能够生成喔~) one 樱花树html 动态生成樱花 效果图( ...

  4. python散点图解_python 画三维图像 曲面图和散点图的示例

    用python画图很多是根据z=f(x,y)来画图的,本博文将三个对应的坐标点输入画图: 散点图: import matplotlib.pyplot as plt from mpl_toolkits. ...

  5. python极坐标绘图_Python 画极坐标图

    需要用Python画极坐标等值线图,以下是所学的一些东西,特此记录 -------------------------------------------------- 你应该能够像往常一样使用极地图 ...

  6. python roc曲线_python画roc

    广告关闭 腾讯云11.11云上盛惠 ,精选热门产品助力上云,云服务器首年88元起,买的越多返的越多,最高返5000元! 以下是使用scikit learn预测.做出决策边界并画出roc曲线的一个示例, ...

  7. python绘制蝴蝶_python画蝴蝶曲线图的实例

    蝴蝶曲线是由Temple H·Fay发现的可用极坐标函数表示的蝴蝶曲线. 由于此曲线优美, 因此就想把它作为博客favicon.ico,这里我使用pytho matplotlib.pyplot包来绘制 ...

  8. python樱花树代码_Python画樱花树

    import turtle as T import random import time # 画樱花的躯干(60,t) def Tree(branch, t): time.sleep(0.0005) ...

  9. python 六维图_Python 画出来六维图

    来自维基百科 我们的大脑通常最多能感知三维空间,超过三维就很难想象了.尽管是三维,理解起来也很费劲,所以大多数情况下都使用二维平面. 不过,我们仍然可以绘制出空间,今天就来用 Python 的 plo ...

最新文章

  1. “光名字就想了一年”,苹果三位高管谈M1芯片
  2. ASP.NET Core MVC上传、导入、导出知多少
  3. Hadoop学习之以全分布模式部署及问题
  4. 机房精密空调压缩机故障处理实例
  5. HTML在手机上实现直接拨打电话以及发送短信
  6. html怎么设计自己的网页,求一份自己设计的简单网页 HTML格式
  7. 无奈!《花木兰》《速度与激情9》等多部影片宣布撤档
  8. vue下拉框传值问题
  9. 计算机误删怎么恢复数据,电脑资料数据误删怎么恢复?
  10. php 接收传值_php接受post传值的方法
  11. FastDFS配置之常见错误
  12. Hbase命令设置TTL/编码设置TTL
  13. kaldi_源码笔记 thchs-30_data_prep
  14. 分享一些做课题调查的方法
  15. 2020全国工业互联网安全技术技能大赛Web题WP
  16. 分层图解决的一些最短路问题
  17. 【超详细word排版】页眉:宋体五号,居中排列。左面页眉为论文题目,右面页眉为章次和章标题。页眉底划线的宽度为0.75磅。 页码:宋体小五号,排在页眉行的最外侧,不加任何修饰。
  18. plsql报错:Not logged on
  19. 大数据开发常用命令大全 大全
  20. RT-Thread学习笔记|TCS34725 RGB 颜色识别传感器详解

热门文章

  1. Counting Liars
  2. win10网络显示已连接到服务器异常,如何解决win10网络连接配置异常的问题
  3. noip冲刺计划(no regrets,no fear)
  4. cardboard下载_如何在Android上设置Google Cardboard
  5. DSP28335 CAN模块例程
  6. 修改UINavigationItem标题字体
  7. 基于Graphhopper的路线导航方案
  8. 不懂就学——什么是input和output?
  9. JS第二次授课及字节跳动2017秋招前端工程师笔试试卷涉及知识点
  10. 危化品从业人员考试题目及答案