# 代码由 离鲸鲸鲸 原创
# 有问题请联系微信号 innoin 沟通处理
from turtle import *
from math import sqrt
from random import random, randint
class Heart:
def __init__(self, x, y, size):
self.size = size # 心形大小
self.speed = size # 移动速度根据大小变化
# 设置画笔的统一属性
t = Turtle(visible=False, shape='circle')
t.shapesize(size, size)
color = (1, 1- size/4, 1-size/4) # 颜色修改为根据大小变化的粉色
t.pencolor(color)
t.fillcolor(color)
t.penup()
# 克隆一个圆形,设置位置
self.circle1 = t.clone()
self.circle1.goto(x-sqrt(size*size*160)/2, y)
# 克隆第二个圆形,设置位置
self.circle2 = t.clone()
self.circle2.goto(x+sqrt(size*size*160)/2, y)
# 克隆一个正方形,设置位置并旋转角度
self.square = t.clone()
self.square.shape("square")
self.square.setheading(45)
self.square.goto(x, y-sqrt(size * size * 160)/2)
python进行表白,画爱心
最新推荐文章于 2024-04-28 16:45:28 发布