Given a circle centered at (200,200), radius 25, how do I draw an arc from 270 degree to 135 degree and one that goes from 270 to 45 degree?
0 degree means it is right on the x-axis (the right side) (meaning it is 3 o' clock position) 270 degree means it is 12 o'clock position, and 90 means it is 6 o'clock position
More generally, what is a path for an arc for part of a circle with
x, y, r, d1, d2, direction
meaning
center (x,y), radius r, degree_start, degree_end, direction
I wanted to comment on @Ahtenus answer, specifically on Ray Hulha comment saying the codepen does not show any arc, but my reputation is not high enough.
The reason for this codepen not working is that its html is faulty with a stroke-width of zero.
I fixed it and added a second example here : http://codepen.io/AnotherLinuxUser/pen/QEJmkN.
The html :
The relevant CSS :
The javascript :
I slightly modified the answer of opsb and made in support fill for the circle sector. http://codepen.io/anon/pen/AkoGx
JS
HTML
@opsb's answers is neat, but the center point is not accurate, moreover, as @Jithin noted, if the angle is 360, then nothing is drawn at all.
@Jithin fixed the 360 issue, but if you selected less than 360 degree, then you'll get a line closing the arc loop, which is not required.
I fixed that, and added some animation in the code below:
you can use JSFiddle code i made for answer above:
https://jsfiddle.net/tyw6nfee/
all you need to do is change last line console.log code and give it your own parameter:
A slight modification to @opsb's answer. We cant draw a full circle with this method. ie If we give (0, 360) it will not draw anything at all. So a slight modification made to fix this. It could be useful to display scores that sometimes reach 100%.
An image and some Python
Just to clarify better and offer another solution.
Arc
[A
] command use the current position as a starting point so you have to useMoveto
[M] command first.Then the parameters of
Arc
are the following:If we define for example the following svg file:
The following code will give you this result:
You will set the starting point with
M
the ending point with the parametersxf
andyf
ofA
.We are looking for circles so we set
rx
equal tory
doing so basically now it will try to find all the circle of radiusrx
that intersect the starting and end point.You can have a more detailed explanation in this post that I wrote.