Javascript code written below is displaying numbers on an analog watch, but i am not able to understand the logic of for loop mentioned in the code. Can anybody please explain this logic?
function drawNumbers(ctx, radius) {
var ang;
var num;
ctx.font = radius*0.15 + "px arial"; //set font at 15% of radius
ctx.textBaseline = "middle"; //set text alignment to middle
ctx.textAlign = "center"; //set text alignment to center
for(num=1; num < 13; num++){ //calculate the print position for each number
ang = num *Math.PI /6;
ctx.rotate(ang);
ctx.translate(0, -radius*0.85);
ctx.rotate(-ang);
ctx.fillText(num.toString(), 0, 0);
ctx.rotate(ang);
ctx.translate(0, radius*0.85);
ctx.rotate(-ang);
}
}
i tried to debug the code with the help of browser but i was not able to reach any conclusion as i am not able to grasp the logic used to display numbers.