Python画生日蛋糕

import turtle as t
import math as m
import random as r
import time
screen = t.getscreen()
t.speed(0)
t.delay(0)
# t.tracer(0, 0)def drawX(a, i):angle = m.radians(i)return a * m.cos(angle)def drawY(b, i):angle = m.radians(i)return b * m.sin(angle)# 设置背景颜色,窗口位置以及大小
t.bgcolor("#d3dae8")
t.setup(1000, 800)
t.penup()
t.goto(150, 0)
t.pendown()
# 1
t.pencolor("white")
t.begin_fill()
for i in range(360):x = drawX(150, i)y = drawY(60, i)t.goto(x, y)
t.fillcolor("#fef5f7")
t.end_fill()
# 2
t.begin_fill()
for i in range(180):x = drawX(150, -i)y = drawY(70, -i)t.goto(x, y)
for i in range(180, 360):x = drawX(150, i)y = drawY(60, i)t.goto(x, y)
t.fillcolor("#f2d7dd")
t.end_fill()
# 3
t.pu()
t.goto(120, 0)
t.pd()
t.begin_fill()
for i in range(360):x = drawX(120, i)y = drawY(48, i)t.goto(x, y)
t.fillcolor("#cbd9f9")
t.end_fill()
# 4
t.begin_fill()
t.pencolor("#fee48c")
for i in range(540):x = drawX(120, i)y = drawY(48, i) + 70t.goto(x, y)
t.goto(-120, 0)
t.fillcolor("#cbd9f9")
t.end_fill()
# 5
t.pu()
t.goto(120, 70)
t.pd()
t.pencolor("#fff0f3")
t.begin_fill()
for i in range(360):x = drawX(120, i)y = drawY(48, i) + 70t.goto(x, y)
t.fillcolor("#fff0f3")
t.end_fill()
# 6
t.pu()
t.goto(110, 70)
t.pd()
t.pencolor("#fff9fb")
t.begin_fill()
for i in range(360):x = drawX(110, i)y = drawY(44, i) + 70t.goto(x, y)
t.fillcolor("#fff9fb")
t.end_fill()
# 7
t.pu()
t.goto(120, 0)
t.pd()
t.begin_fill()
t.pencolor("#ffa79d")
for i in range(180):x = drawX(120, -i)y = drawY(48, -i) + 10t.goto(x, y)
t.goto(-120, 0)
for i in range(180, 360):x = drawX(120, i)y = drawY(48, i)t.goto(x, y)
t.fillcolor("#ffa79d")
t.end_fill()
# 8
t.pu()
t.goto(120, 70)
t.pd()
t.begin_fill()
t.pensize(4)
t.pencolor("#fff0f3")
for i in range(1800):x = drawX(120, 0.1 * i)y = drawY(-18, i) + 10t.goto(x, y)
t.goto(-120, 70)
t.pensize(1)
for i in range(180, 360):x = drawX(120, i)y = drawY(48, i) + 70t.goto(x, y)
t.fillcolor("#fff0f3")
t.end_fill()
# 9
t.pu()
t.goto(80, 70)
t.pd()
t.begin_fill()
t.pencolor("#6f3732")
t.goto(80, 120)
for i in range(180):x = drawX(80, i)y = drawY(32, i) + 120t.goto(x, y)
t.goto(-80, 70)
for i in range(180, 360):x = drawX(80, i)y = drawY(32, i) + 70t.goto(x, y)
t.fillcolor("#6f3732")
t.end_fill()
# 10
t.pu()
t.goto(80, 120)
t.pd()
t.pencolor("#ffaaa0")
t.begin_fill()
for i in range(360):x = drawX(80, i)y = drawY(32, i) + 120t.goto(x, y)
t.fillcolor("#ffaaa0")
t.end_fill()
# 11
t.pu()
t.goto(70, 120)
t.pd()
t.pencolor("#ffc3be")
t.begin_fill()
for i in range(360):x = drawX(70, i)y = drawY(28, i) + 120t.goto(x, y)
t.fillcolor("#ffc3be")
t.end_fill()
# 12
t.pu()
t.goto(80, 120)
t.pd()
t.begin_fill()
t.pensize(3)
t.pencolor("#ffaaa0")
for i in range(1800):x = drawX(80, 0.1 * i)y = drawY(-12, i) + 80t.goto(x, y)
t.goto(-80, 120)
t.pensize(1)
for i in range(180, 360):x = drawX(80, i)y = drawY(32, i) + 120t.goto(x, y)
t.fillcolor("#ffaaa0")
t.end_fill()
# 13
t.pu()
t.goto(64, 120)
t.pd()
t.pencolor("#b1c9e9")
t.begin_fill()
for i in range(360):x = drawX(4, i) + 60y = drawY(1, i) + 120t.goto(x, y)
t.goto(64, 170)
for i in range(540):x = drawX(4, i) + 60y = drawY(1, i) + 170t.goto(x, y)
t.goto(56, 120)
t.fillcolor("#b1c9e9")
t.end_fill()
t.pencolor("white")
t.pensize(2)
for i in range(1, 6):t.goto(64, 120 + 10 * i)t.pu()t.goto(56, 120 + 10 * i)t.pd()
t.pu()
t.goto(60, 170)
t.pd()
t.goto(60, 180)
t.pensize(1)
#
t.pu()
t.goto(64, 190)
t.pd()
t.pencolor("#f1add1")
t.begin_fill()
for i in range(360):x = drawX(4, i) + 60y = drawY(10, i) + 190t.goto(x, y)
t.fillcolor("#f1add1")
t.end_fill()# 14
t.pu()
t.goto(-56, 120)
t.pd()
t.pencolor("#b1c9e9")
t.begin_fill()
for i in range(360):x = drawX(4, i) - 60y = drawY(1, i) + 120t.goto(x, y)
t.goto(-56, 170)
for i in range(540):x = drawX(4, i) - 60y = drawY(1, i) + 170t.goto(x, y)
t.goto(-64, 120)
t.fillcolor("#b1c9e9")
t.end_fill()
t.pencolor("white")
t.pensize(2)
for i in range(1, 6):t.goto(-56, 120 + 10 * i)t.pu()t.goto(-64, 120 + 10 * i)t.pd()
t.pu()
t.goto(-60, 170)
t.pd()
t.goto(-60, 180)
t.pensize(1)
#
t.pu()
t.goto(-56, 190)
t.pd()
t.pencolor("#f1add1")
t.begin_fill()
for i in range(360):x = drawX(4, i) - 60y = drawY(10, i) + 190t.goto(x, y)
t.fillcolor("#f1add1")
t.end_fill()
# 15
t.pu()
t.goto(0, 130)
t.pd()
t.pencolor("#b1c9e9")
t.begin_fill()
for i in range(360):x = drawX(4, i)y = drawY(1, i) + 130t.goto(x, y)
t.goto(4, 180)
for i in range(540):x = drawX(4, i)y = drawY(1, i) + 180t.goto(x, y)
t.goto(-4, 130)
t.fillcolor("#b1c9e9")
t.end_fill()
t.pencolor("white")
t.pensize(2)
for i in range(1, 6):t.goto(4, 130 + 10 * i)t.pu()t.goto(-4, 130 + 10 * i)t.pd()
t.pu()
t.goto(0, 180)
t.pd()
t.goto(0, 190)
t.pensize(1)
#
t.pu()
t.goto(4, 200)
t.pd()
t.pencolor("#f1add1")
t.begin_fill()
for i in range(360):x = drawX(4, i)y = drawY(10, i) + 200t.goto(x, y)
t.fillcolor("#f1add1")
t.end_fill()
# 16
t.pu()
t.goto(30, 110)
t.pd()
t.pencolor("#b1c9e9")
t.begin_fill()
for i in range(360):x = drawX(4, i) + 30y = drawY(1, i) + 110t.goto(x, y)
t.goto(34, 160)
for i in range(540):x = drawX(4, i) + 30y = drawY(1, i) + 160t.goto(x, y)
t.goto(26, 110)
t.fillcolor("#b1c9e9")
t.end_fill()
t.pencolor("white")
t.pensize(2)
for i in range(1, 6):t.goto(34, 110 + 10 * i)t.pu()t.goto(26, 110 + 10 * i)t.pd()
t.pu()
t.goto(30, 160)
t.pd()
t.goto(30, 170)
t.pensize(1)
#
t.pu()
t.goto(34, 180)
t.pd()
t.pencolor("#f1add1")
t.begin_fill()
for i in range(360):x = drawX(4, i) + 30y = drawY(10, i) + 180t.goto(x, y)
t.fillcolor("#f1add1")
t.end_fill()
# 17
t.pu()
t.goto(-30, 110)
t.pd()
t.pencolor("#b1c9e9")
t.begin_fill()
for i in range(360):x = drawX(4, i) - 30y = drawY(1, i) + 110t.goto(x, y)
t.goto(-26, 160)
for i in range(540):x = drawX(4, i) - 30y = drawY(1, i) + 160t.goto(x, y)
t.goto(-34, 110)
t.fillcolor("#b1c9e9")
t.end_fill()
t.pencolor("white")
t.pensize(2)
for i in range(1, 6):t.goto(-26, 110 + 10 * i)t.pu()t.goto(-34, 110 + 10 * i)t.pd()
t.pu()
t.goto(-30, 160)
t.pd()
t.goto(-30, 170)
t.pensize(1)
#
t.pu()
t.goto(-26, 180)
t.pd()
t.pencolor("#f1add1")
t.begin_fill()
for i in range(360):x = drawX(4, i) - 30y = drawY(10, i) + 180t.goto(x, y)
t.fillcolor("#f1add1")
t.end_fill()
###随机
color = ["#e28cb9", "#805a8c", "#eaa989", "#6e90b7", "#b8b68f", "#e174b5", "#cf737c", "#7c8782"]
for i in range(80):t.pu()x = r.randint(-120, 120)y = r.randint(-25, 30)t.goto(x, y)t.pd()t.dot(r.randint(2, 5), color[r.randint(0, 7)])
for i in range(40):t.pu()x = r.randint(-90, 90)y = r.randint(-35, 10)t.goto(x, y)t.pd()t.dot(r.randint(2, 5), color[r.randint(0, 7)])for i in range(40):t.pu()x = r.randint(-80, 80)y = r.randint(60, 90)t.goto(x, y)t.pd()t.dot(r.randint(2, 5), color[r.randint(0, 7)])
for i in range(30):t.pu()x = r.randint(-50, 50)y = r.randint(45, 70)t.goto(x, y)t.pd()t.dot(r.randint(2, 5), color[r.randint(0, 7)])
for i in range(50):t.pu()x = r.randint(-500, 500)y = r.randint(120, 300)t.goto(x, y)t.pd()t.dot(r.randint(3, 5), color[r.randint(0, 7)])
t.seth(90)
t.pu()
t.goto(0, 0)
t.fd(210)
t.left(90)
t.fd(170)
t.pd()
t.write("我的女孩,生日快乐", font=("Curlz MT", 28))
t.done()screen.mainloop()

Python画生日蛋糕相关推荐

  1. Python画生日蛋糕源码

    源码 import turtle as t import math as m import random as r def drawX(a, i):angle = m.radians(i)return ...

  2. 用Python画个生日蛋糕为朋友庆生

    每当有朋友过生日时,生日蛋糕自然是必不可少的,今天我们来看一下如何用 Python 画一个生日蛋糕. 本文我们用到的 Python 库包括:turtle.math 和 random. 实现的主要代码如 ...

  3. 拜托,有一个python画的生日蛋糕超酷的好吧~

    前言: 相信大家对生日蛋糕不陌生吧! 今天给大家分享一下用代码写个生日蛋糕出来,拜托,有一个python画的生日蛋糕超酷的好吧~ 代码: import turtle as t import math ...

  4. 用Python画一个生日蛋糕并写上生日祝福对象及生日祝福语

    用Python画一个生日蛋糕并写上生日祝福对象及生日祝福语.画一个双层蛋糕并点上蜡烛.代码运行时间较长,请静待惊喜出现,代码运行截图: 完整程序代码: 干货主要有: ① 200 多本 Python 电 ...

  5. Python小项目【画玫瑰花、画生日蛋糕、】

    1.画玫瑰花 import turtle import time turtle.speed(5) #画笔移动的速度,数值越大速度越快# 设置初始位置 turtle.penup() #提起画笔,移动画笔 ...

  6. 用Python制作生日蛋糕、生日快乐,生日祝福代码

    用Python画一个生日蛋糕并写上生日祝福对象及生日祝福语.画一个双层蛋糕并点上蜡烛.代码运行时间较长,请静待惊喜出现,代码运行截图: 点击免费领取<CSDN大礼包>: 最新全套[Pyth ...

  7. 怎么用python画个电脑_python语言还是java如何用python画爱心

    用python绘制爱心的基本步骤如下: 002pc.com对<python语言还是java如何用python画爱心>总结来说,为我们学习Python很实用. 首先先下载安装好python程 ...

  8. 开学季,教你用Python画大学教室座位神分区图!网友直呼“中枪”

    作者 | 丁彦军 转载自恋习Python(ID:sldata2017) 我们上过大学的朋友们都知道,大学没有固定教室也没有固定的座位,所以大家可以随便找个自己喜欢的位置坐下. 别看这些不起眼的座位,感 ...

  9. 圣诞节!教你用Python画棵圣诞树

    作者 | 糖甜甜甜,985高校经管研二,擅长用 Python.R.tableau 等工具结合统计学和机器学习模型做数据分析. 来源 | 经管人学数据分析(ID:DAT-2017) 如何用Python画 ...

最新文章

  1. 根据开源数据库选择合适的工具
  2. ctf(pwn) canary保护机制讲解 与 解密方法介绍
  3. Linux网络基本网络配置
  4. HTML基础-张晨光-专题视频课程
  5. 98. Validate Binary Search Tree
  6. Spring Boot基础学习笔记07:Spring Boot整合JPA
  7. 无法import的原因(ImportError: No module named *****)
  8. Android 手势放大图片
  9. 批处理删除7天以上的文件
  10. Hadoop学习笔记三
  11. macbook历代_你都见过吗?苹果Mac历代台式机回忆录
  12. 堆溢出off-by-one(asis-ctf-2016 pwn 之 b00ks)
  13. PHP 大数据处理思路
  14. Matplotlib自定义图例(多张独立图共享图例)
  15. Deepin系统标题栏及其按钮美化
  16. adb控制移动数据、wifi开关、下拉菜单栏
  17. Web安全防攻(渗透测试)
  18. 电视上玩android游戏,如何用u盘下载游戏在android系统电视上玩?
  19. 加解密篇 - 什么是加密加盐 (分析web3j的加盐处理)
  20. 如何计算冲突域和广播域-图解分析

热门文章

  1. HBase Shell基础操作命令
  2. Filter过滤器(1)
  3. ACM - 贪心 - 基础(区间问题 + Huffman树 + 排序不等式 + 绝对值不等式 + 推公式)
  4. metricbeat mysql_Metricbeat 参考指南(目录)
  5. IT十年人生过客-终篇-十年总结
  6. Python编程获得本机所有网络链接的ip地址
  7. [转载]t检验、t分布、t值
  8. 全语言通用的ASCIL表讲解,这一篇就够了
  9. 未解决的问题记录——微信小程序开发提示:系统错误
  10. 学习能力篇:怎么用S-G学习法做总结?