Como renderizar um círculo svg usando start e endAngle
Eu renderizei o círculo svg usando start e endAngle. Funcionou bem. Mas quando renderizo o círculo completo (startAngle como 70 e endAngle como 70) a saída é muito diferente (exceto 0, 90, 180, 270). o que eu fiz de errado para esse código?
function getPathArc(center, start, end, radius) {
end -= this.isCompleteAngle(start, end) ? 0.0001 : 0;
var degree = end - start;
degree = degree < 0 ? (degree + 360) : degree;
return this.getCirclePath(
center, getLocationFromAngle(start, radius, center),
getLocationFromAngle(end, radius, center), radius, (degree < 180) ? 0 : 1
);
}
function getCirclePath(center, start, end, radius, clockWise) {
return 'M ' + start.x + ' ' + start.y + ' A ' + radius + ' ' +
radius + ' 0 ' + clockWise + ' 1 ' + end.x + ' ' + end.y;
}
function getLocationFromAngle(degree, radius, center) {
var radian = (degree * Math.PI) / 180;
return {
x : Math.cos(radian) * radius + center.x,
y : Math.sin(radian) * radius + center.y
}
}
function isCompleteAngle(startAngle, endAngle) {
var totalAngle = endAngle - startAngle;
totalAngle = totalAngle <= 0 ? (totalAngle + 360) : totalAngle;
return Math.floor(totalAngle / 360) !== 0;
}
Exemplo de link:https://jsfiddle.net/fNPvf/43106/
O círculo verde é renderizado corretamente porque o início e o fim do ângulo são 90, mesmo que eu mude o ângulo como 0, 180, 270 e 360, ele funcionará. mas o problema real é o círculo vermelho, que eu uso 70, até o problema ocorrerá, exceto os ângulos (0, 90, 180, 270, 360).
como resolver esse problema?