// Colour Wheel — Adobe Illustrator compatible
// Places N ellipses evenly around a circle, each hue-rotated.
#target illustrator

var doc = app.activeDocument;

var count = 24;
var cx = 260, cy = 220, ringR = 150, dotR = 28;

function hsbToRgb(h, s, b) {
    h = (h % 360) / 60; s /= 100; b /= 100;
    var i = Math.floor(h), f = h - i;
    var p = b * (1 - s), q = b * (1 - s * f), t = b * (1 - s * (1 - f));
    var r, g, bl;
    switch (i) {
        case 0: r = b; g = t; bl = p; break;
        case 1: r = q; g = b; bl = p; break;
        case 2: r = p; g = b; bl = t; break;
        case 3: r = p; g = q; bl = b; break;
        case 4: r = t; g = p; bl = b; break;
        default: r = b; g = p; bl = q;
    }
    var c = new RGBColor();
    c.red = Math.round(r * 255); c.green = Math.round(g * 255); c.blue = Math.round(bl * 255);
    return c;
}

for (var i = 0; i < count; i++) {
    var ang = i / count * 2 * Math.PI;
    var x = cx + ringR * Math.cos(ang) - dotR;
    var y = cy + ringR * Math.sin(ang) - dotR;

    var dot = doc.pathItems.ellipse(y, x, dotR * 2, dotR * 2);
    dot.fillColor = hsbToRgb(i / count * 360, 90, 100);
    dot.stroked = false;
}

app.redraw();
