Skip to main content
Known Participant
October 4, 2023
Question

Can I automatically give every subsequent letter a different color for a batch of text designs?

  • October 4, 2023
  • 3 replies
  • 1623 views

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

This topic has been closed for replies.

3 replies

Kurt Gold
Community Expert
Community Expert
October 4, 2023

I answered in your other thread here:

 

https://community.adobe.com/t5/illustrator-discussions/re-can-you-automatically-give-every-subsequent-letter-a-different-color-for-a-batch-of-text-designs/td-p/14133014

 

But as it obviously is associated, here you can get a script, kindly provided by Sky Chaser High:

 

Random Text Colour

 

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.

 

MiamoreAuthor
Known Participant
October 4, 2023

The Random Text Colour script is not exactly what I want because its giving random colors, but Femke's one works well

jane-e
Community Expert
Community Expert
October 4, 2023

@Miamore 

 

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:

 

https://community.adobe.com/t5/photoshop-ecosystem-discussions/can-you-automatically-give-every-subsequent-letter-a-different-color-for-a-batch-of-text-designs/td-p/12325456

 

Jane

 

MiamoreAuthor
Known Participant
October 4, 2023

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?"

Ton Frederiks
Community Expert
Community Expert
October 4, 2023

Femkes script will work as you want.

femkeblanco
Legend
October 4, 2023
  1. Is there a set of colors to choose from, or should the script generate the colors? 
  2. Should the color be different from the color of the preceding letter, or all preceding letters in a body of text? 
MiamoreAuthor
Known Participant
October 4, 2023

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.

femkeblanco
Legend
October 4, 2023

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;
    }
}