Can I automatically give every subsequent letter a different color for a batch of text designs?
Copy link to clipboard
Copied
Hello,
I'm searching help for a task, I want to generate a batch of text images in which each individual letter is colored differently. If I create a text and then put a different color on each letter there is no problem but if I want to use variables to produce different text it applies the same effect of the first letter to the full text, this is forcing me to enter each Ai file and re color each letter. I'm curious if there's a method or a script to automatically ensure that each successive letter in every text image receives a unique color. For example, I want the first letter of the text to be bleu, second to be yellow, thirt to be pink, and then it repeats, forth letter to be bleu, fifth to be yellow, sixth to be pink, etc
Thank you in advance
Explore related tutorials & articles
Copy link to clipboard
Copied
- Is there a set of colors to choose from, or should the script generate the colors?
- Should the color be different from the color of the preceding letter, or all preceding letters in a body of text?
Copy link to clipboard
Copied
Hi, I was thinking on using specific colors (not randomly generated), and each letter should be different in a sequancial mode, like for example for word "The Bank", using for example 3 colors (green, pink, red), it should be "T" green, "h" pink, "e" red, "B" green again, "a" pink again, "n" red again, "k" green and so on.
Copy link to clipboard
Copied
Create a color group with the desired colors in the desired order, select the color group and the text, and run
var colors = app.activeDocument.swatches.getSelected();
var chars = app.selection[0].characters;
var counter = 0;
for (var i = 0; i < chars.length; i++) {
if (chars[i].contents != " ") {
chars[i].characterAttributes.fillColor = colors[counter].color;
if (counter < colors.length - 1) counter++;
else counter = 0;
}
}
Copy link to clipboard
Copied
Yey! Thank you very much, exactly what I needed 🙂
Copy link to clipboard
Copied
Is it possible to have something like this for each word, each line of text (if there is an ENTER) and each sentence?
Copy link to clipboard
Copied
I've moved your post to the Illustrator forum for you, as the PS script is not likely to work in Illustrator.
For reference, here is the image and link to the Photoshop thread:
Jane
Copy link to clipboard
Copied
Hi, thank you, yes I noted that so I have created this new thread, only that now I am not able to comment in the one that is for phorothop, I wante to post this
"Also for your script, its trying to apply a color for the spaces too, so for example if I want to use three different colors (bleu, yellow, pink) for the phrase "The Bank", 1st letter will be bleu, 2nd will be yellow, 3rd will be pink, the space is taking in account as a character so it is trying to put it as bleu, so the letter B (4th letter but 5th in placement if we take in account the space), will be yellow instead of bleu, is there a way to adjust this please?"
Copy link to clipboard
Copied
Femkes script will work as you want.
Copy link to clipboard
Copied
Ah yes, this particular question was intended to go to the original thread (the photoshop one), it was open at the time I asked the 1st question but then I created a new thread for Illustator and it was moved here and the photoshop one was marked as solved so I can't ask for adjustements on the provided scipt there (I guess I will need to open a new one asking for that)
Copy link to clipboard
Copied
I answered in your other thread here:
But as it obviously is associated, here you can get a script, kindly provided by Sky Chaser High:
Options available: by word, character or sentence. You may try to modify it, so it suits your needs.
And of course, try Femke's very good approach.
Copy link to clipboard
Copied
The Random Text Colour script is not exactly what I want because its giving random colors, but Femke's one works well

