转换成心脏2d android

对不起,但我的数学和物理太弱,所以我尝试了很多次,但每次我失败,我需要你的帮助来完成我的应用程序PLZ转换这个圆圈的心脏

import android.graphics.Bitmap; public class Circle { float origRadius,deltaRadius,radius,origX,deltaX,x,origY,deltaY,y; int color,alpha,steps,currentStep; Bitmap bitmap; public Circle(float xCenter, float yCenter, float radius, int color, int steps) { this.x = xCenter; this.origX = xCenter; this.deltaX = (float) (40.0 * Math.random() - 20.0); this.y = yCenter; this.origY = yCenter; this.deltaY = (float) (40.0 * Math.random() - 20.0); this.origRadius = radius; this.radius = radius; this.deltaRadius = 0.5f * radius; this.color = color; this.alpha = 0; this.steps = steps; } void tick() { this.currentStep++; float fraction = (float) this.currentStep / (float) this.steps; this.radius = this.origRadius + fraction * this.deltaRadius; this.x = this.origX + fraction * this.deltaX; this.y = this.origY + fraction * this.deltaY; if (fraction  this.steps; } } 

提前致谢

MathWorld具有很棒的心形function; http://mathworld.wolfram.com/HeartCurve.html

基本上你必须在你的代码中做这样的事情;

 float fraction = (float) this.currentStep / (float) this.steps; 

– >

 float t = this.currentStep * 2.0 * Math.PI / (float) this.steps; this.x = 16.0 * Math.pow(Math.sin(t), 3.0)); this.y = 13.0 * Math.cos(t) - 5.0 * Math.cos(2.0 * t) - 2.0 * Math.cos(3.0 * t) - Math.cos(4.0 * t); 

希望这会有所帮助,我会盲目地写这个,所以如果有一些错误,请耐心等待。 对于radius,您可能想要做这样的事情;

 this.x *= radius / 16.0; this.y *= radius / 16.0;