Cómo representar un círculo svg usando start y endAngle
He renderizado el círculo svg usando start y endAngle. Funcionó bien. Pero cuando renderizo el círculo completo (startAngle como 70 y endAngle como 70) la salida es muy diferente (excepto el 0, 90, 180, 270). ¿Qué hice mal para este 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;
}
Enlace de muestra:https://jsfiddle.net/fNPvf/43106/
El círculo verde se representa correctamente porque el ángulo inicial y final es 90, incluso si cambio el ángulo como 0, 180, 270 y 360 funcionará. pero el problema real es el círculo rojo que utilizo 70, incluso el problema vendrá excepto esos ángulos (0, 90, 180, 270, 360).
¿Cómo solucionar este problema?