android - How to create a resizable circle with user touch events? -
i trying create circle shape resized on ontouchevent.
i have followed resizable rectangle post, think due lack of mathematics knowledge, not getting how create resizeable circle.
i have tried changing
canvas.drawrect( left + colorballs.get(0).getwidthofball() / 2, top + colorballs.get(0).getwidthofball() / 2, right + colorballs.get(2).getwidthofball() / 2, bottom + colorballs.get(2).getwidthofball() / 2, paint);
to canvas.drawcircle(); creates circle not quite wanted.
can please tell me there thing implemented or points should follow convert rectangle example resizable circle.
so, center of circle be:
float cx = (left + right) / 2f; float cy = (top + bottom) / 2f;
-- quite obvious. radius can calculated using math.hypot()
:
float radius = math.hypot(top - bottom, right - left) / 2f;
thus, have center , radius draw circle:
drawcircle(cx, cy, radius, paint);
Comments
Post a Comment