[英]Drawing a square in canvas
I have a canvas that is drawing a circle with predefined bounds. 我有一块画布正在绘制具有预定义范围的圆。
canvas.drawCircle((float) (getBounds().right / 2), (float) (getBounds().bottom / 2), (float) (getBounds().right / 2), paint);
and now I need to make it draw a square instead of a circle. 现在我需要使其绘制一个正方形而不是一个圆形。 so this is what I modified
所以这就是我修改的
(getBounds().right / 2)
instead of it dividing by 2
I didn't divide it by anything for the radius (getBounds().right / 2)
而不是除以2
我没有将半径除以任何东西
how ever it just overflows. 怎么会溢出。
So this is how it looks like when its a normal circle. 因此,这是正常圆时的样子。
and this is how it looks when I attempted to make it a square 这就是我尝试使其变成正方形时的外观
can someone please suggest me how I can draw a successful square with the bounds I have been given? 有人可以建议我如何用给定的边界绘制成功的正方形吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.