在Java中由于某种原因Ellipse2D.Double
使用参数(height, width, x, y)
当我创建一个RectF
在Android中参数是(left, top, right, bottom)
所以我对适应差异有点困惑。
如果在 Java 中创建一个椭圆并使用以下命令:
//Ellipse2D.Double(height, width, x, y)
x = 100;
y = 120;
centerX = getWidth() / 2;
centerY = getHeight() / 2;
//Ellipse2D.Double(100, 120, (centerX - 100) * 2, (centerY - 120) * 2);
new Ellipse2D.Double(x, y, (centerX - x) * 2, (centerY - y) * 2);
这对于 Android 来说是等价的吗:
//RectF(left, top, right, bottom)
x = 100;
y = 120;
centerX = getWidth() / 2;
centerY = getHeight() / 2;
new RectF((centerX - 100) * 2, (centerY - 120) * 2), 120 - ((centerX - 100) * 2), 100 - ((centerY -120) * 2);
//canvas.drawOval(myRectF, paint);
我不太确定它们是否相等,并且想知道我的计算是否正确?
或者,可以重写RectF
使其类似于如何Ellipse2D
? IE。更改要使用的参数高度和宽度而不是右侧和底部?