function polarToCartesian(centerX, centerY, radius, angleInDegrees) {
var angleInRadians = (angleInDegrees-90) * Math.PI / 180.0;
return {
x: centerX + (radius * Math.cos(angleInRadians)),
y: centerY + (radius * Math.sin(angleInRadians))
};
}
function describeArc(x, y, radius, startAngle, endAngle){
var start = polarToCartesian(x, y, radius, endAngle);
var end = polarToCartesian(x, y, radius, startAngle);
var largeArcFlag = endAngle - startAngle <= 180 ? "0" : "1";
var sweepFlag = endAngle > startAngle ? 0 : 1; //sic
var d = [
"M", start.x, start.y,
"A", radius, radius, 0, largeArcFlag, sweepFlag, end.x, end.y
].join(" ");
return d;
}
var correctPath = document.getElementById('correctPath'),
incorrectPath = document.getElementById('incorrectPath'),
expectedPath = document.getElementById('expectedPath');
correctPath.setAttribute('d', describeArc(24,24,20,0,90));
incorrectPath.setAttribute('d', describeArc(24,24,20,90,0));
expectedPath.setAttribute('d', 'M24 2.75 a 1 1 1 1 1 0 42.8');
.col {width: 32%; float: left; padding: 0.5%}
<div class="col">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48">
<defs>
<path d="" id="correctPath"></path>
</defs>
<circle r="24" cx="24" cy="24" fill="#eee"></circle>
<text id="nameText" fill="green" font-size="3.2">
<textPath xlink:href="#correctPath">counterclockwise</textPath>
</text>
</svg>
</div>
<div class="col">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48">
<defs>
<path d="" id="incorrectPath"></path>
</defs>
<circle r="24" cx="24" cy="24" fill="#eee"></circle>
<text id="nameText" fill="red" font-size="3.2">
<textPath xlink:href="#incorrectPath">clockwise</textPath>
</text>
</svg>
</div>
<div class="col">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48">
<defs>
<path d="" id="expectedPath"></path>
</defs>
<circle r="24" cx="24" cy="24" fill="#eee"></circle>
<text id="nameText" fill="blue" font-size="3.2">
<textPath xlink:href="#expectedPath">expected</textPath>
</text>
</svg>
</div>