I have a 400x300 HTML Canvas and I'm trying to draw a sun using a circle and 7 triangles. To draw the triangles, I do a translate, rotate, translate as indicated on this SO Answer. However, some of the triangles overlap as though they have the same angle.
http://codepen.io/ralrom/pen/bgZYRO
I can't figure out what's wrong, I checked the calculated radians and they all fall between 0 and 2*PI.
var drawSun = function () {
// Circle
context.beginPath();
context.arc(75, 75, 30, 0, Math.PI * 2, true);
context.closePath();
context.fill();
context.save();
// Triangles
for (var i = 0; i < 7; i++) {
// Rotate the canvas around a point
angle = i * 360 / 7;
console.log(angle, angle * Math.PI / 180);
context.translate(75, 75);
context.rotate(angle * Math.PI / 180);
context.translate(-75, -75);
// Draw the triangle
context.beginPath();
context.fillStyle = 'rgba(0,0,0,0.5)';
context.moveTo(60, 35);
context.lineTo(75, 15);
context.lineTo(90, 35);
context.closePath();
context.fill();
context.restore();
}
}