由于某种原因,在 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
以使其类似于 how Ellipse2D
?IE。更改参数以使用高度和宽度而不是右侧和底部?