当前位置:   article > 正文

python画心代码_frame math import sin, cos,pi,log代码错误

frame math import sin, cos,pi,log代码错误

 

import random
from math import sin,cos,pi,log
from tkinter import *
CANVAS_WIDTH = 640
CANVAS_HEIGHT = 640;
CANVAS_CENTER_X = CANVAS_WIDTH/2
CANVAS_CENTER_Y = CANVAS_HEIGHT/2
IMAGE_ENLARGE = 11
HEART_COLOR = "#ff7171"

def heart(t,shrink_ratio:float = IMAGE_ENLARGE):
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)

def scatter(x,y,beta=0.15):
ratio_x = -beta * log(random.random())
ratio_y = -beta * log(random.random())

dx = ratio_x * (x - CANVAS_CENTER_X)
dy = ratio_y * (y - CANVAS_CEN

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/192242
推荐阅读
相关标签
  

闽ICP备14008679号