// This macro displays, as a montage, all the LUTs in the
// Image>Lookup Tables menu.

saveSettings();
list = getList("LUTs");
setBatchMode(true);
newImage("ramp", "8-bit Ramp", 256, 32, 1);
newImage("luts", "RGB White", 256, 48, 1);
count = 0;
setForegroundColor(255, 255, 255);
setBackgroundColor(255, 255, 255);
setFont("SansSerif", 12,"antialiased");
for (i=0; i<list.length; i++) {
    selectWindow("ramp");
    run(list[i]);
    run("Select All");
    run("Copy");
    selectWindow("luts");
    makeRectangle(0, 0, 256, 32);
    run("Paste");
    setJustification("center");
    setColor(0, 0, 0);
    drawString(list[i],128, 48);
    run("Add Slice");
    run("Select All");
    run("Clear", "slice");
    count++;
}
run("Delete Slice");
rows = floor(count/4);
if (rows<count/4) rows++;
run("Canvas Size...", "width=258 height=50 position=Center");
run("Make Montage...", "columns=4 rows="+rows
+" scale=1 first=1 last="+count+" increment=1 border=0 use");
rename("Lookup Tables");
setBatchMode(false);
restoreSettings();
