Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw points images on edge of circle of image

enter image description here

I'm really stuck on how to go about programming this. How to draw a circle in Android Canvas with a radius and points around the edge?

What is best approach to design this?

like image 449
user991429 Avatar asked Aug 06 '13 11:08

user991429


2 Answers

the point(cX,cY) you want draw

the center point(centerX,centerY) of the circle

the radius of the circle

the angle is the point(cX,cY) on the circle.

also see the image:

http://i.stack.imgur.com/2Dx2r.jpg

the code:

cX = centerX + radius*Math.cos(angle*Math.PI/180);
cY = centerY + radius*Math.sin(angle*Math.PI/180);
canvas.drawCircle(cX, cY, radius, paint); 
like image 157
Sea Avatar answered Oct 19 '22 09:10

Sea


Well; drawing a circle is a very straightforward, inside your onDraw() method add this line

canvas.drawCircle(cX, cY, radius, paint); 

Simply provide the center point's x and y values and radius and paint object as well.

And for the pins around the corner you can go like this, e.g you want a pin at 30 degrees; with a simple trigonometric calculation, your pin's x and y values can be these;

pX = mX + radius * Math.cos(Math.toRadians(30));
pY = mY + radius * Math.sin(Math.toRadians(30));

So you can draw your pin at these x and y values respectively, also the degree can be changed.

like image 38
Onur A. Avatar answered Oct 19 '22 10:10

Onur A.