我试过下面的代码,如果矩形的宽度与它的高度相同,它会绘制一个很好的圆的近似值;但它并没有画出一个很大的椭圆形,“角落”非常尖锐。有什么建议么?如何使用贝塞尔曲线近似椭圆以填充给定的矩形?
float width = rect.width();
float height = rect.height();
float centerX = rect.width()/2;
float centerY = rect.height()/2;
float diameter = Math.min(width, height);
float length = (float) (0.5522847498 * diameter/2);
path.moveTo(0, centerY);
path.cubicTo(0, centerY - length, 0, centerX - length, 0, centerX, 0);
path.cubicTo(centerX + length, 0, width, centerY - length, height, centerY);
path.cubicTo(width, centerY + length, centerX + length, height, centerX, height);
path.cubicTo(centerX - length, height, 0, centerY + length, 0, centerY);
谢谢,这工作完美。 – ab11 2011-04-12 17:08:22