Skip to main content
Known Participant
October 9, 2023
Question

Can I automatically color every subsequent letter with a different color selecting a swatch group?

  • October 9, 2023
  • 3 replies
  • 1860 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 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 orange, thirt to be green, and then it repeats, forth letter to be bleu, fifth to be orange, sixth to be green, etc

Also, I would like to color the text selecting a swatch group if this is possible.

 

For example:

The Bank

 

Thank you in advance

This topic has been closed for replies.

3 replies

c.pfaffenbichler
Community Expert
Community Expert
October 10, 2023

DOM code cannot do that, that needs AM code. 

Did @jazz-y ’s post already solve the issue? 

 

If not please explain the Swatch Group issue with the help of screenshots. (I am not sure this is [easily] possible anyway.) 

MiamoreAuthor
Known Participant
October 10, 2023

Hi, this is not exactly what I am searching, it is a workaround but it has a "space issue" like I posted in jazz's answer, and also its not by selecting swatches (in illustrator to colirize by selecting the swatches group is possible with a script, dont know if in photoshop too)

Stephen Marsh
Community Expert
Community Expert
October 12, 2023

Hi, its giving me an error if I replace that part, "Error 6: Bad digit in number. Line 46" (the one that I replaced). This script does almost the same as the one suggested by Jazz-y, but this one dont use hexadecimal color codes (and are not easy to reach because I need to change them often, I dont know a lot about scipting, so dont know if I can just put that line on top), and the script suggested by Jazz-y is trying to color the spaces but the good thing is that it is using hexadecimal color codes (I work with that and its better to paste for example only 5 codes instead of 15). I have almost what I need with both scripts but sadly not 100% 😞

 


I didn't see the code from jazz-y. So why don't you use that as a guide?

 

Looking at that topic link, the values do need to be wrapped in quotes, so:

 

// the color array;
var theColors = ["004fab", "00cfb3", "ff7000", "14a41c", "ce007d", "2900e7"];
Legend
October 10, 2023
MiamoreAuthor
Known Participant
October 10, 2023

Hi, this is not exactly what I am searching but it's a workaround, only that for this script I need to create a separated script for every swatch group that I want to use and, with this script it is taking in account the "spaces" as characters, so its trying to color the spaces, is there a way to avoid this "spaces issues"? To explain:

This scipt do this:

The Bank

Instead of this:

The Bank

 

Bojan Živković11378569
Community Expert
Community Expert
October 10, 2023

I will tag a few experts who will provide the correct answer and may be able to assist you @c.pfaffenbichler @Stephen Marsh