function RysujGwiazde(cx, cy, ilosc_rogow, zewnetrzny_promien, wewnetrzny_promien) {
var ctx = document.getElementById("my_canvas").getContext('2d');
var rot = Math.PI / 2 * 3;
var x = cx;
var y = cy;
var step = Math.PI / ilosc_rogow;
ctx.strokeSyle = "#000";
ctx.beginPath();
ctx.moveTo(cx, cy - zewnetrzny_promien);
for (i = 0; i < ilosc_rogow; i++) {
x = cx + Math.cos(rot) * zewnetrzny_promien;
y = cy + Math.sin(rot) * zewnetrzny_promien;
ctx.lineTo(x, y);
rot = rot + step;
x = cx + Math.cos(rot) * wewnetrzny_promien;
y = cy + Math.sin(rot) * wewnetrzny_promien;
ctx.lineTo(x, y);
rot = rot + step;
}
ctx.lineTo(cx, cy - zewnetrzny_promien);
ctx.closePath();
ctx.lineWidth = 5;
ctx.strokeStyle = '#f2ac31';
ctx.stroke();
ctx.fillStyle = 'yellow';
ctx.fill();
}
RysujGwiazde(100,100,5,10,30);
Prosze o wyjasnienie dziłania tego programu, został on lekko zmodyfikowany (zrodlo stackoverflow)