I'd like to get something like that in SVG. So far I've made the circles but I want to positionate correctly the black zone around.
An API returns four values:
- start_angle : The first angle (Looks to be a radian)
- end_angle : The final angle (Looks to be a radian)
- inner_radius : The smaller radius
- outer_radius : The bigger radius
Here is a scheme of what I want:
I'm making the SVG with Javascript so my code is something like this:
var myArc = document.createElementNS('http://www.w3.org/2000/svg', 'path');
myArc.setAttribute('fill', 'black');
myArc.setAttribute('d', 'M-'+outer_radius+',32A'+outer_radius+','+outer_radius+' 0 0,1 -'+outer_radius+',-32L-'+inner_radius+',-30A'+inner_radius+','+inner_radius+' 0 0,0 -'+inner_radius+',30Z');// TODO
arcs.appendChild(myArc);
This can draw a single zone but I don't know what values to put in. I've tried to determine the point to use but it doesn't work:
var pointA = [outer_radius * Math.cos(start_angle * 180 / Math.PI), outer_radius * Math.sin(start_angle * 180 / Math.PI)];
var pointB = [outer_radius * Math.cos(end_angle * 180 / Math.PI), outer_radius * Math.sin(end_angle * 180 / Math.PI)];
var pointC = [inner_radius * Math.cos(end_angle * 180 / Math.PI), inner_radius * Math.sin(end_angle * 180 / Math.PI)];
var pointD = [inner_radius * Math.cos(start_angle * 180 / Math.PI), inner_radius * Math.sin(start_angle * 180 / Math.PI)];
Could you help me to solve this issue ?
Thanks for your help.