动态爱心代码-python

浅蹭了一波热度,搞了个简易版本,代码如下:

import numpy as np
import math
from tkinter import *
import random

pi = math.pi

width = 680
height = 680
center_x = width/2
center_y = height/2
color = "#990000"
c2 = '#990000'

#x = 16sint^3
#y = 13cost - 5cos2t - 2cos3t -cos4t
def heart_function(t):
    # t = np.linspace(0,2*pi)
    x = 16*(np.sin(t))**3
    y = 13*np.cos(t) - 5*np.cos(2*t) - 2*np.cos(3*t) - np.cos(4*t)

    return x,y
#在一定范围内随机抖动
def scatter(x,y,ratio):
    while(1):
        rand = random.random()
        if(rand!=0):
            break
    x =  - ratio*math.log10(rand)
    y =  - ratio*math.log2(rand)
    return x,y


#画图

def Graph(x_s,y_s,x0,y0,c=color,shrink_size=11):
    w1,w2 = shrink_size,shrink_size-1 #缩放倍数
    # 内部填充
    add_scatters(x_s, y_s, x0, y0,shrink_size=w2)
    #填充外部
    for j in range(len(x_s)):
        ratio1 = m
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值