convert circle into heart 2d android [closed]

穿精又带淫゛_ 提交于 2019-12-04 22:10:27

MathWorld had a great heart shaped function; http://mathworld.wolfram.com/HeartCurve.html

Basically you have to do something like this in your code;

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);

Hope this helps, I'm writing this blindly so bear with me if there's some mistakes. For radius you might want to do something like this;

this.x *= radius / 16.0;
this.y *= radius / 16.0;
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!