1

I am trying to swap color values - R to G and G to R in my illustration (well, a selection on it). In the end, a (200,100,0) would be (100,200,0). I found various pages that does color swapping and inversion but couldn't figure out a way to do this.

Could anyone help me with that or lead me to an answer if it already exists?

Thanks!

3
  • I think some scripting would be required to do this
    – JohnB
    Commented Oct 1, 2015 at 14:55
  • Thanks for the pointer @JohnB I found a script on another page and modified it a bit. In case anyone else needs it (or wants to improve it), this seems to work for me: var fillRGBColor = function (pathItems){ for (var i=0; i < pathItems.length; i++) { r = pathItems[i].fillColor.red; g = pathItems[i].fillColor.green; pathItems[i].fillColor.red = g; pathItems[i].fillColor.green = r; } } fillRGBColor(app.activeDocument.pathItems); sorry, couldn't manage to get it in a code block
    – meono
    Commented Oct 1, 2015 at 15:27
  • @meono If the script you posted in your comment works and answers the question, you should post that as an answer.
    – AndrewH
    Commented Oct 1, 2015 at 15:46

2 Answers 2

1

Thanks to @JohnB's suggestion, I solved the issue with a simple script. I found a template function on another page and modified it a bit. In case anyone else needs it (or wants to improve it), this seems to work for me:

var fillRGBColor = function (pathItems){
    for (var i=0; i < pathItems.length; i++) {
        r = pathItems[i].fillColor.red;
        g = pathItems[i].fillColor.green;
        pathItems[i].fillColor.red = g;
        pathItems[i].fillColor.green = r;
    }
}

fillRGBColor(app.activeDocument.pathItems);
2
0

Have you tired the Recolor Artwork command?

Select the object(s) that you want to recolor. In this case, I'll change the color of the orange lights on my truck.

truck

With your object(s) selected, go to Edit > Edit Colors > Recolor Artwork

menu

Then you can select which colors you wish to change and edit their values. In this case, I want to change the orange lights (200,100,0) to the green you gave (100,200,0). Next to the orange bar, you will see a rectangle split in half (circled in blue). Double-click that rectangle and the color picker dialog box pops up, like in my example below.

options

When you've swapped your colors, click Ok.

truck2

3
  • Yes but if there are 150 colors?
    – joojaa
    Commented Oct 1, 2015 at 15:22
  • Yes, my issue was too many colors (basically a red-yellow-green spectrum). I think I solved the issue with a script - which I'll comment above in a sec
    – meono
    Commented Oct 1, 2015 at 15:25
  • I thought he was only swapping the values on one color
    – Manly
    Commented Oct 1, 2015 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.