首页 分享 python浪漫表白,送她小花花

python浪漫表白,送她小花花

来源:花匠小妙招 时间:2025-06-30 23:12

原创

©著作权归作者所有:来自51CTO博客作者azure01的原创作品,请联系作者获取转载授权,否则将追究法律责任

想要别出心裁给女朋友准备一个惊喜,就用我们所学过的python代码来写一个表白程序。

代码如下

# -*- coding:utf-8 -*- # @Time : 2023/2/14 13:52 # @Author: Azure # @File: Valentines_day.py import turtle as t from time import sleep from PIL import Image import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D def init(): t.speed(2) t.pensize(2) t.screensize(480, 360) t.color('red', 'red') # 输出文字 printer = t.Turtle() printer.hideturtle() printer.penup() printer.back(200) printer.write("送给我的宝贝nn", align="right", font=("楷体", 16, "bold")) printer.write("from xxx", align="center", font=("楷体", 12, "normal")) def draw_heart_right(): t.up() t.goto(50, 50) t.pendown() t.right(45) t.goto(100, 0) t.seth(45) t.fd(120) t.circle(50, 225) def draw_heart_left(): t.up() t.goto(0, 0) t.down() t.seth(45) t.fd(120) t.circle(50, 225) t.seth(90) t.circle(50, 225) t.fd(120) def draw_arrow(): t.up() t.seth(0) # 羽毛 t.goto(-210, 40) t.pendown() t.goto(-215, 44) t.goto(-190, 49) t.goto(-175, 46) t.up() t.goto(-210, 40) t.pendown() t.goto(-213, 34) t.goto(-185, 39) t.goto(-175, 46) t.up() # 箭杆 t.pendown() t.goto(0, 80) t.penup() t.goto(160, 110) t.pendown() t.goto(320, 140) # 箭羽 t.left(160) t.begin_fill() t.fd(10) t.left(120) t.fd(10) t.left(120) t.fd(10) t.end_fill() def mgh(): fig = plt.figure() ax = fig.add_subplot(projection = '3d') # 将相位向后移动了6*pi [x, t] = np.meshgrid(np.array(range(25)) / 24.0, np.arange(0, 575.5, 0.5) / 575 * 20 * np.pi + 4*np.pi) p = (np.pi / 2) * np.exp(-t / (8 * np.pi)) # 添加边缘扰动 change = np.sin(15*t)/150 # 将t的参数减少,使花瓣的角度变大 u = 1 - (1 - np.mod(3.3 * t, 2 * np.pi) / np.pi) ** 4 / 2 + change y = 2 * (x ** 2 - x) ** 2 * np.sin(p) r = u * (x * np.sin(p) + y * np.cos(p)) h = u * (x * np.cos(p) - y * np.sin(p)) c= plt.get_cmap('Reds') surf = ax.plot_surface(r * np.cos(t), r * np.sin(t), h, rstride=1, cstride=1, cmap= c, linewidth=0, antialiased=True) plt.show() if __name__ == '__main__': init() draw_heart_right() draw_heart_left() draw_arrow() t.hideturtle() # t.done() sleep(1) mgh() # zp() 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.98.99.100.101.102.103.104.105.106.107.108.109.110.111.112.113.114.115.116.117.118.119.120.121. 收藏 评论 举报

相关知识

python七夕浪漫表白
教你用Python浪漫表白
《教你用Python写出浪漫的表白代码》
今天520! 教你用Python浪漫表白
七夕到了——属于Python的浪漫,拿去吧~ 祝表白成功
python爱心表白 每天都是浪漫七夕!
JAVA表白浪漫烟花效果代码
【Python表白系列】用代码画玫瑰花,属于程序员的浪漫告白(完整代码)
Python表白代码:5个步骤,用代码打造独一无二的表白
python浪漫背景表白

网址: python浪漫表白,送她小花花 https://www.huajiangbk.com/newsview2099923.html

所属分类:花卉
上一篇: 从花香到心香:“花香伴我行”插花
下一篇: 520表白日,唯有鲜花不可辜负,

推荐分享