赞
踩
大部分人都有喜欢的人,学会这些表白代码,下次表白你肯定会成功。希望你有个女朋友
第一个方法
第二个方法
部分源码
import sys import os import random import pygame from pygame.locals import * WIDTH, HEIGHT = 640, 480 BACKGROUND = (255, 255, 255) def button(text, x, y, w, h, color, screen, size): pygame.draw.rect(screen, color, (x, y, w, h)) font = pygame.font.Font('carton.ttf', size) textRender = font.render(text, True, (0, 0, 0)) textRect = textRender.get_rect() textRect.center = ((x+w/2), (y+h/2)) screen.blit(textRender, textRect) def title(text, screen, scale, color=(0, 0, 0)): font = pygame.font.Font('carton.ttf', WIDTH//(len(text)*2)) textRender = font.render(text, True, color) textRect = textRender.get_rect() textRect.midtop = (WIDTH/scale[0], HEIGHT/scale[1]) screen.blit(textRender, textRect) def get_random_pos(): x, y = random.randint(20, 620), random.randint(20, 460) return x, y def show_like_interface(text, screen, color=(255, 0, 0)): screen.fill(BACKGROUND) font = pygame.font.Font('carton.ttf', WIDTH//(len(text))) textRender = font.render(text, True, color) textRect = textRender.get_rect() textRect.midtop = (WIDTH/2, HEIGHT/2) screen.blit(textRender, textRect) pygame.display.update() while True: for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit()
部分源码
print('\n'.join([line for line in [''.join([('Love'[(x-y) % len('Love')] if ((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3 <= 0 else ' ') for x in range(-30, 30)])
部分源码
import turtle import time # 清屏函数 def clear_all(): turtle.penup() turtle.goto(0, 0) turtle.color('white') turtle.pensize(800) turtle.pendown() turtle.setheading(0) turtle.fd(300) turtle.bk(600) # 重定位海龟的位置 def go_to(x, y, state): turtle.pendown() if state else turtle.penup() turtle.goto(x, y) # 画线 # state为真时海龟回到原点,为假时不回到原来的出发点 def draw_line(length, angle, state): turtle.pensize(1) turtle.pendown() turtle.setheading(angle) turtle.fd(length) turtle.bk(length) if state else turtle.penup() turtle.penup() # 画箭羽 def draw_feather(size): angle = 30 # 箭的倾角 feather_num = size//6 # 羽毛的数量 feather_length = size // 3 # 羽毛的长度 feather_gap = size//10 # 羽毛的间隔 for i in range(feather_num): draw_line(feather_gap, angle+180, False) # 箭柄,不折返 draw_line(feather_length, angle + 145, True) # 羽翼,要折返 draw_line(feather_length, angle + 145, False) draw_line(feather_num*feather_gap, angle, False) draw_line(feather_length, angle + 145 + 180, False) for i in range(feather_num): draw_line(feather_gap, angle+180, False) # 箭柄,不折返 draw_line(feather_length, angle - 145, True) # 羽翼,要折返 draw_line(feather_length, angle - 145, False) draw_line(feather_num*feather_gap, angle, False) draw_line(feather_length, angle - 145 + 180, False)
部分源码
import turtle import math turtle.pen() t = turtle t.up() t.goto(0, 150) t.down() t.color('red') t.begin_fill() t.fillcolor('red') t.speed(1) t.left(45) t.forward(150) t.right(45) t.forward(100) t.right(45) t.forward(100) t.right(45) t.forward(100) t.right(45) t.forward(250 + math.sqrt(2) * 100) t.right(90) t.speed(2) t.forward(250 + 100 * math.sqrt(2)) t.right(45) t.forward(100) t.right(45) t.forward(100) t.right(45) t.forward(100) t.right(45) t.forward(150) t.end_fill() t.goto(-10, 0) t.pencolor('white') # L t.pensize(10) t.goto(-50, 0) t.goto(-50, 80) t.up() # I t.goto(-100, 0) t.down() t.goto(-160, 0) t.goto(-130, 0) t.goto(-130, 80) t.goto(-160, 80) t.goto(-100, 80) t.up()
部分源码
import random from math import sin, cos, pi, log from tkinter import * CANVAS_WIDTH = 640 # 画布的宽 CANVAS_HEIGHT = 640 # 画布的高 CANVAS_CENTER_X = CANVAS_WIDTH / 2 # 画布中心的X轴坐标 CANVAS_CENTER_Y = CANVAS_HEIGHT / 2 # 画布中心的Y轴坐标 IMAGE_ENLARGE = 11 # 放大比例 HEART_COLOR = "#e77c8e" # 心的颜色#ff7171 def heart_function(t, shrink_ratio: float = IMAGE_ENLARGE): """ “爱心函数生成器” :param shrink_ratio: 放大比例 :param t: 参数 :return: 坐标 """ # 基础函数 x = 16 * (sin(t) ** 3) y = -(13 * cos(t) - 5 * cos(2 * t) - 2 * cos(3 * t) - cos(4 * t)) # 放大 x *= shrink_ratio y *= shrink_ratio # 移到画布中央 x += CANVAS_CENTER_X y += CANVAS_CENTER_Y return int(x), int(y)
import random from math import sin, cos, pi, log from tkinter import * CANVAS_WIDTH = 840 # 画布的宽 CANVAS_HEIGHT = 680 # 画布的高 CANVAS_CENTER_X = CANVAS_WIDTH / 2 # 画布中心的X轴坐标 CANVAS_CENTER_Y = CANVAS_HEIGHT / 2 # 画布中心的Y轴坐标 IMAGE_ENLARGE = 11 # 放大比例 HEART_COLOR = "RED" # 引号内修改颜色! def heart_function(t, shrink_ratio: float = IMAGE_ENLARGE): """ “爱心函数生成器” :param shrink_ratio: 放大比例 :param t: 参数 :return: 坐标 """ # 基础函数 x = 17 * (sin(t) ** 3) y = -(16 * cos(t) - 5 * cos(2 * t) - 2 * cos(3 * t) - cos(3 * t)) # 放大 # x *= shrink_ratio # y *= shrink_ratio x *= IMAGE_ENLARGE y *= IMAGE_ENLARGE # 移到画布中央 x += CANVAS_CENTER_X y += CANVAS_CENTER_Y return int(x), int(y) def scatter_inside(x, y, beta=0.15): """ 随机内部扩散 :param x: 原x :param y: 原y :param beta: 强度 :return: 新坐标 """ ratio_x = - beta * log(random.random()) ratio_y = - beta * log(random.random()) dx = ratio_x * (x - CANVAS_CENTER_X) dy = ratio_y * (y - CANVAS_CENTER_Y) return x - dx, y - dy
6款Python表白代码领取地址:提取码:关注微信公众号祖龙科技工作室回复python表白即可获取
网站源码
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。