How to draw image points on the edge of the image circle

enter image description here

I really got stuck on how to program this. How to draw a circle in Android Canvas with radius and dots around the edge?

What is best suited for its development?

+7
android android canvas
source share
2 answers

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

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

Just specify the x and y values โ€‹โ€‹of the center point and the radius and the drawing object.

And you can go behind the pins around the corner, for example, you want the pin to be at an angle of 30 degrees; with a simple trigonometric calculation, your x and y values โ€‹โ€‹could be like this:

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

Thus, you can draw your output with these values โ€‹โ€‹of x and y, respectively, also the degree can be changed.

+2
source share

point (cX, cY) you want to spend

center point (center X, center Y) of the circle

circle radius

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

also see 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); 
+5
source share

All Articles