Python浪漫表白源码合集(爱心、玫瑰花、照片墙、星空下的告白)「建议收藏」

您所在的位置:网站首页 c语言表白的程序代码怎么写 Python浪漫表白源码合集(爱心、玫瑰花、照片墙、星空下的告白)「建议收藏」

Python浪漫表白源码合集(爱心、玫瑰花、照片墙、星空下的告白)「建议收藏」

2024-05-19 10:45| 来源: 网络整理| 查看: 265

大家好,又见面了,我是你们的朋友全栈君。

​  

Python浪漫表白源码合集(爱心、玫瑰花、照片墙、星空下的告白)「建议收藏」Python浪漫表白源码合集(爱心、玫瑰花、照片墙、星空下的告白)「建议收藏」

来源:百度动图

在这里插入图片描述在这里插入图片描述

我发现网上有很多写得很好的Python表白代码,感觉绘出来的图很漂亮。我整理了一下,挑了一些我觉得不错的代码和部分自认不错的原创分享给大家(这些我都测试过,确实可以生成喔~),选一种喜欢的方式发给你的那个她/他吧。

Python浪漫表白源码合集(爱心、玫瑰花、照片墙、星空下的告白)「建议收藏」Python浪漫表白源码合集(爱心、玫瑰花、照片墙、星空下的告白)「建议收藏」1. 一行代码画爱心代码语言:javascript复制print('\n'.join([''.join([('Love'[(x-y)%4]if((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3 5: # 剩余树枝太少要结束递归 if branchLen < 20: # 如果树枝剩余长度较短则变绿 t.color("green") t.pensize(random.uniform((branchLen + 5) / 4 - 2, (branchLen + 6) / 4 + 5)) t.down() t.forward(branchLen) love(t.xcor(), t.ycor()) # 传输现在turtle的坐标 t.up() t.backward(branchLen) t.color("brown") return t.pensize(random.uniform((branchLen + 5) / 4 - 2, (branchLen + 6) / 4 + 5)) t.down() t.forward(branchLen) # 以下递归 ang = random.uniform(15, 45) t.right(ang) tree(branchLen - random.uniform(12, 16), t) # 随机决定减小长度 t.left(2 * ang) tree(branchLen - random.uniform(12, 16), t) # 随机决定减小长度 t.right(ang) t.up() t.backward(branchLen) myWin = turtle.Screen() t = turtle.Turtle() t.hideturtle() t.speed(1000) t.left(90) t.up() t.backward(200) t.down() t.color("brown") t.pensize(32) t.forward(60) tree(100, t) myWin.exitonclick()

效果图

在这里插入图片描述在这里插入图片描述Python浪漫表白源码合集(爱心、玫瑰花、照片墙、星空下的告白)「建议收藏」Python浪漫表白源码合集(爱心、玫瑰花、照片墙、星空下的告白)「建议收藏」1. 星空下的告白代码语言:javascript复制""" 代码用途:表白 作者:阿黎逸阳 """ def bgpic(self, picname=None): """Set background image or return name of current backgroundimage. Optional argument: picname -- a string, name of a gif-file or "nopic". If picname is a filename, set the corresponding image as background. If picname is "nopic", delete backgroundimage, if present. If picname is None, return the filename of the current backgroundimage. Example (for a TurtleScreen instance named screen): >>> screen.bgpic() 'nopic' >>> screen.bgpic("landscape.gif") >>> screen.bgpic() 'landscape.gif' """ if picname is None: return self._bgpicname if picname not in self._bgpics: self._bgpics[picname] = self._image(picname) self._setbgpic(self._bgpic, self._bgpics[picname]) self._bgpicname = picname # coding: utf-8 import pygame import os import sys from pygame.locals import * os.chdir('F:/微信公众号/Python/29.加载音乐') os.getcwd() pygame.init() pygame.mixer.init() pygame.mixer.music.load("告白.mp3") #pygame.mixer.music.set_volume(0.4) pygame.mixer.music.play() bg_size = width, height = 300, 200 bg_rgb = (255, 255, 255) screen1 = pygame.display.set_mode(bg_size) pygame.display.set_caption("告白音乐") clock = pygame.time.Clock() play_image = pygame.image.load("开始和暂停按钮2.png").convert_alpha() pause_image = pygame.image.load("开始和暂停按钮2.png").convert_alpha() pause_rect = pause_image.get_rect() print(pause_rect.width,pause_rect.height) pause_rect.left, pause_rect.top = (width - pause_rect.width) // 2, (height - pause_rect.height) // 2 from turtle import * from random import random,randint os.chdir('F:/微信公众号/Python/0.已发表') screen = Screen() width ,height = 900,700 screen.setup(width,height) screen.title("告白") screen.bgcolor("black") screen.bgpic(r'./星空下互相告白的两个人2.gif') screen.mode("logo") screen.delay(0) printer = Turtle() printer.hideturtle() printer.penup() printer.color('red') printer.goto(-100,-350) printer.write("In the whole universe\n\n",move = True, align="left", font=("Italic", 30, "bold")) printer.goto(-50,-400) printer.write("YZ I only love you!\n\n",move = True, align="left", font=("Italic", 30, "bold")) t = Turtle(visible = False,shape='circle') t.pencolor("white") t.fillcolor("white") t.penup() t.setheading(-90) t.goto(width/2,randint(-height/2,height/2)) stars = [] for i in range(300): star = t.clone() s =random()/3 if s>0.01 and s0.03 and s0.05 and s0.15 and s0.19 and s0.21 and s0.29 and s0.31 and s0.32 and s


【本文地址】


今日新闻


推荐新闻


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