// Spiral Path — Adobe Illustrator compatible
// Builds a single stroked path from computed anchor points (pathItems.add + setEntirePath).
#target illustrator

var doc = app.activeDocument;

var cx = 260, cy = 220;
var turns = 5, stepsPerTurn = 40;
var total = turns * stepsPerTurn;
var maxR = 170;

var pts = [];
for (var i = 0; i <= total; i++) {
    var t = i / total;
    var ang = t * turns * 2 * Math.PI;
    var r = t * maxR;
    pts.push([cx + r * Math.cos(ang), cy + r * Math.sin(ang)]);
}

var spiral = doc.pathItems.add();
spiral.setEntirePath(pts);
spiral.closed = false;
spiral.filled = false;
spiral.stroked = true;

var col = new RGBColor();
col.red = 40; col.green = 90; col.blue = 220;
spiral.strokeColor = col;
spiral.strokeWidth = 2;

app.redraw();
$.writeln("Spiral with " + pts.length + " points.");
