Allow to sort swatches by Hue, Saturation, Luminosity and other values
Right now AI allow to globally sort swatches by name and kind. It is not enough though.
1. I need to sort each group in it's own way (automatically) — thefeore I need context menu to work with color groups with needed options
2. I need more sorting parameters
3. I need each group to remember sorting and have a checkmark near it in said context menus
I guess it could also be tucked in palette menu, but I can't give you a way to keep compatibility with current global sorting behavior.
Please figure this out.
-
Donn L Pierson commented
please
-
Donn L Pierson commented
Add Sort Function that allow us to Sort Color Swatches by HUE, BRIGHTNESS and/or SATURATION. Abobe, this request has been in the Hopper for many years…please get this feature launched!!
-
Donn L Pierson commented
Adobe...friends...Let's go!!!
This request to be able to Sort Swatches by HUE...has been in the hopper for quite some time. -
Malea Ember commented
@Aaron thank you SO much for this script!! This is exactly what I was looking for! Super helpful that you can adjust the swatch names as well in-script. You rock.
-
Aaron commented
@Łukasz Martynowicz: The scripts maintain the order from top to bottom of the selection. the built in version doesn't. the built in appears to start from the center and then work itself out towards the edges without duplicates. here is a script that applies the first color group to a selection from bottom to top.
and also one to reverse order of the first color group
// Script to fill a selection of objects from top to bottom with the colors of the first swatch group in swatches panel in Adobe Illustrator
function applySwatchColorsToSelection(swatchGroup) {
var doc = app.activeDocument; // Access the active document
var selection = doc.selection; // Access the current selectionif (selection.length === 0) {
alert("No objects found. Please select some objects and try again.");
return;
}if (!swatchGroup || swatchGroup.typename !== "SwatchGroup") {
alert("Unable to find the first color group swatch.");
return;
}// Sort the selected objects by their top position (reverse order)
selection = selection.slice().sort(function (a, b) {
return b.geometricBounds[1] - a.geometricBounds[1];
});var swatchColors = swatchGroup.getAllSwatches();
for (var i = 0; i < selection.length; i++) {
var item = selection[i];
if (item.typename === "PathItem") {
var colorIndex = i % swatchColors.length;
item.fillColor = swatchColors[colorIndex].color;
}
}
}function getFirstSwatchGroup() {
var doc = app.activeDocument; // Access the active document
var swatchGroups = doc.swatchGroups;if (swatchGroups.length > 1) {
return swatchGroups[1];
}return null;
}var firstSwatchGroup = getFirstSwatchGroup();
applySwatchColorsToSelection(firstSwatchGroup);to reverse colors
// Reverse the order of the swatches in the first color group swatch
#target illustrator
function reverseFirstColorGroupSwatch() {
if (app.documents.length == 0) {
alert("No open documents.");
return;
}var doc = app.activeDocument;
var colorGroups = doc.swatchGroups;
if (colorGroups.length <= 1) {
alert("No color groups found.");
return;
}var firstColorGroup = colorGroups[1];
var swatches = firstColorGroup.getAllSwatches();
var swatchesLength = swatches.length;for (var i = 0; i < swatchesLength / 2; i++) {
var swatchA = swatches[i];
var swatchB = swatches[swatchesLength - 1 - i];var tempColor = swatchA.color;
swatchA.color = swatchB.color;
swatchB.color = tempColor;
}
}reverseFirstColorGroupSwatch();
-
Łukasz Martynowicz commented
@Aaron: how are those different from the built in option of creating swatch group from selected artwork?
-
Aaron commented
For what it's worth, I made a script that can take selected objects and turn them into a color group swatch from top to bottom. if you apply an effect like crystallize to a photo and then trace it, flatten it(flatten transparency. or expand(maybe), and then ungroup it(i still forget that), you can run the script. it is nice to preserve the natural flow of colors from nature. I've attached two scripts one with duplicates and one without
// Script to create a color group swatch from the fill colors(includes duplicates) of selected Ungrouped objects in Adobe Illustrator
function createSwatchFromSelectedFills() {
var doc = app.activeDocument; // Access the active document
var selection = doc.selection; // Access the current selectionif (selection.length === 0) {
alert("No objects found. Please select some objects and try again.");
return;
}// Sort the selected objects by their top position (reverse order)
selection = selection.slice().sort(function (a, b) {
return b.geometricBounds[1] - a.geometricBounds[1];
});var newSwatchGroup = doc.swatchGroups.add();
newSwatchGroup.name = "GeneratedSwatchGroup";for (var i = 0; i < selection.length; i++) {
var item = selection[i];
if (item.typename === "PathItem") {
var newColor = item.fillColor;
var newSwatch = doc.swatches.add();
newSwatch.name = "Color_" + (i + 1);
newSwatch.color = newColor;
newSwatchGroup.addSwatch(newSwatch);
}
}
}createSwatchFromSelectedFills();
here is the second one
// Script to create a color group swatch from the fill colors(no duplicates) of selected Ungrouped objects in Adobe Illustrator
function createSwatchFromSelectedFills() {
var doc = app.activeDocument; // Access the active document
var selection = doc.selection; // Access the current selectionif (selection.length === 0) {
alert("No objects found. Please select some objects and try again.");
return;
}// Sort the selected objects by their top position (reverse order)
selection = selection.slice().sort(function (a, b) {
return b.geometricBounds[1] - a.geometricBounds[1];
});var newSwatchGroup = doc.swatchGroups.add();
newSwatchGroup.name = "GeneratedSwatchGroup";var uniqueColors = {};
var uniqueCount = 0;for (var i = 0; i < selection.length; i++) {
var item = selection[i];
if (item.typename === "PathItem") {
var newColor = item.fillColor;
var colorKey = colorToString(newColor);if (!uniqueColors[colorKey]) {
uniqueColors[colorKey] = true;
uniqueCount++;
var newSwatch = doc.swatches.add();
newSwatch.name = "Color_" + uniqueCount;
newSwatch.color = newColor;
newSwatchGroup.addSwatch(newSwatch);
}
}
}
}function colorToString(color) {
if (color.typename === "RGBColor") {
return "RGB_" + color.red + "_" + color.green + "_" + color.blue;
} else if (color.typename === "CMYKColor") {
return "CMYK_" + color.cyan + "_" + color.magenta + "_" + color.yellow + "_" + color.black;
} else {
return color.toString();
}
}createSwatchFromSelectedFills();
-
Rachel Maheras commented
I agree, this is especially helpful in ALL programs, and especially when painting in ps ect.
-
Joseph Sorensen commented
Really hope this gets implemented some day.
-
Donn L Pierson commented
I have a feature request to consider for a future iteration of illustrator (or possibly all suite products).
In illustrator in a swatch library or in your swatch panel you have the option to sort by swatch name or by swatch type right now. It would be really great to be able to sort by swatch hue. So you could see your swatches almost how a pantone book shows them. Sometimes you're just looking for a lighter grey or a darker blue from a limited swatch palette and it would be easier to do that if you could sort them by their color rather than by the name.
Just an idea for consideration. Thank you!
-
Илья Абрамович commented
There's already a Hue/Lightness sort in Recolor Artwork panel.
Would be perfect if the same sort was avaliable in Swatches menu so that it would be easier to Recolor Artwork with swatch groups. -
[Deleted User] commented
Native sorting would be a great feature. While we have to think about the solution in JavaScript
-
Rob Hutchings commented
I came to add this feature request but you've beat me to it by nearly 3 years @Egor so I'll add my voice here instead ;)
A lot of times you need to pick up artwork from other files. The option to add selected colours to the swatches panel helps heaps with this type of workflow. The feature enhancement requested here would go a step further in this scenario as they seem to get added in a really jumbled up, haphazard way.
Heck! I'd be happy if it only got me 80-90% of the way there in terms of sorting by an approximation of colour similarity as that sure beats starting from scratch.
But ideally if you could get it so once sorted our swatches appeared like when you open a Pantone swatch book that'd be perfect ... Cheers!