python程序员的浪漫

您所在的位置:网站首页 c语言画生日蛋糕 python程序员的浪漫

python程序员的浪漫

2023-09-15 07:21| 来源: 网络整理| 查看: 265

python程序员的浪漫-千行生日祝福代码 🍀 花哨简介🌿 完整代码🌸 写到最后📧 Summary

📆Date: 2022年12月16日修改 🎬Author: 小 y 同 学 📃Classify: 花里胡哨区 🔖Language: Python

🍀 花哨简介

    使用python的turtle库进行绘图,先是绘制“一只大熊”送上祝福,随后绘制三层蛋糕送上浪漫!近千行的生日祝福代码还不赶快去试试!

    小提示:python3的turtle库好像是自带的,不需要安装哦~

🌿 完整代码 # _*_coding:utf-8_*_ # created by cy on 2022/12/16 import turtle as t import time import math as m import random as r # 设置画布 t.setup(1.0, 1.0) # todo 此处可以设置窗体的大小比例 t.bgcolor('white') # 设置背景色 t.title('生日快乐!') # 设置窗口的标题 # todo 此处可以设置绘图速度 t.speed(2) # 速度 t.delay(2) # 延迟 # t.tracer(False) # 一次性出图,便于调试程序使用 t.shape('turtle') # 设置画笔形状 # 称呼 t.penup() t.goto(-500, 250) msg = '昵称' # todo 此处可以修改昵称 for i in msg: t.color('green') t.write(i, True, align='left', font=('方正舒体', 70, 'normal')) time.sleep(0.3) # 大熊 # 左耳 t.color('black') t.penup() t.goto(-150, 200) t.setheading(160) t.begin_fill() t.pendown() t.circle(-30, 230) t.setheading(180) t.circle(37, 90) t.end_fill() # 右耳 t.penup() t.goto(60, 200) t.setheading(20) t.begin_fill() t.pendown() t.circle(30, 230) t.setheading(0) t.circle(-37, 90) t.end_fill() # 头 t.pensize(5) t.penup() t.goto(-113, 237) t.setheading(30) t.pendown() t.circle(-134, 60) t.penup() t.goto(-150, 200) t.setheading(-120) t.pendown() t.circle(200, 80) t.penup() t.goto(60, 200) t.setheading(-60) t.pendown() t.circle(-200, 80) t.penup() t.setheading(210) t.pendown() t.circle(-120, 60) # 左眼 t.speed(10) t.delay(1) # 眼圈 t.penup() t.goto(-140, 100) t.setheading(-45) t.begin_fill() t.pendown() a = 0.2 for i in range(120): if 0


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3