
import random
from math import sin, cos, pi, log
from tkinter import Tk, Canvas# 画布参数
CANVAS_WIDTH = 800
CANVAS_HEIGHT = 600
CANVAS_CENTER_X = CANVAS_WIDTH / 2
CANVAS_CENTER_Y = CANVAS_HEIGHT / 2
EPSILON = 1e-8 # 避免除零错误# 蓝色主题
BLUE_DARK = "#003366" # 深蓝色
BLUE_MEDIUM = "#0066CC" # 中蓝色
BLUE_LIGHT = "#66CCFF" # 浅蓝色
BLUE_HIGHLIGHT = "#99EEFF" # 高亮蓝
BACKGROUND_COLOR = "black" # 背景色# 基础爱心公式
def heart_function(t, shrink_ratio=1.0):x = 16 * (sin(t) ** 3)y = 13 * cos(t) - 5 * cos(2 * t) - 2 * cos(3 * t) - cos(4 * t)x *= shrink_ratioy *= shrink_ratioreturn x, y# 单个蝴蝶类
class Butterfly:def __init__(self, x, y, size=1.0, phase_offset=0):self.x = x # 蝴蝶中心位置xself.y = y # 蝴蝶中心位置yself.size