// Star Burst — Adobe Illustrator compatible
// Scatters stars of varying size and colour, each on its own layer group.
#target illustrator

var doc = app.activeDocument;

var group = doc.groupItems.add();
group.name = "Star Burst";

var n = 20;
var W = doc.width, H = doc.height;

// deterministic pseudo-random so the result is reproducible
var seed = 1234;
function rnd() { seed = (seed * 9301 + 49297) % 233280; return seed / 233280; }

for (var i = 0; i < n; i++) {
    var cx = 40 + rnd() * (W - 80);
    var cy = 40 + rnd() * (H - 80);
    var outer = 15 + rnd() * 45;
    var star = group.pathItems.star(cx, cy, outer, outer * 0.45, 5 + Math.floor(rnd() * 4));

    var col = new RGBColor();
    col.red = Math.round(120 + rnd() * 135);
    col.green = Math.round(rnd() * 120);
    col.blue = Math.round(120 + rnd() * 135);
    star.fillColor = col;
    star.stroked = false;
    star.rotate(rnd() * 72);
}

app.redraw();
$.writeln("Placed " + n + " stars in group '" + group.name + "'.");
