简体   繁体   English

如何在Android中的画布上的路径内绘制圆

[英]How to draw a circle inside a path on canvas in Android

I want to draw a circle inside a path on canvas. 我想在画布上的路径内画一个圆。 To draw a circle, center co-ordinates and radius are required. 要绘制一个圆,需要中心坐标和半径。

How can I calculate the center co-ordinates and radius for a circle inside a path? 如何计算路径内圆的中心坐标和半径?

The path which you have created might be of irregular shape,it may not contain circle properly,anyways, You can create a RectF from the Path and then get the center point of the RectF , 您创建的路径可能是不规则形状,可能没有正确包含圆形,无论如何,您可以从该Path创建一个RectF ,然后获取RectF

    RectF mRectF = new RectF(); 
    mOverlayPath.computeBounds(mRectF, true);//here, mOverlayPath is your path
    float cX = mRectF.centerX();
    float cY = mRectF.centerY();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM