Function Repository Resource:

RainbowText

Source Notebook

Make any text fabulous by coloring the letters with rainbow colors

Contributed by: Katja Della Libera

ResourceFunction["RainbowText"]["string"]

displays string in the colors of the rainbow.

ResourceFunction["RainbowText"]["string", brightness]

uses the specified brightness.

Details and Options

The text will no longer be a string, but rather a list of the letters of different colors represented in a Row.
The brightness argument to ResourceFunction["RainbowText"] should be a number between 0 and 1. The default value of brightness is 0.8.

Examples

Basic Examples (1) 

Display some text in rainbow colors:

In[1]:=
ResourceFunction["RainbowText"]["supercalifragilisticexpialidocious"]
Out[1]=

Scope (1) 

By changing the brightness argument, you can make your text darker or brighter:

In[2]:=
ResourceFunction["RainbowText"]["Just a hint of rainbow", 0.35]
Out[2]=
In[3]:=
ResourceFunction["RainbowText"]["Bright rainbow", 1]
Out[3]=

Possible Issues (2) 

Because the output is not a string, it will not automatically wrap at correct word breaks to fit the page, but instead may break anywhere within a word:

In[4]:=
ResourceFunction[
 "RainbowText"]["Normally, we would like this text to start on a new line at the end of a word once it goes off the page. Unfortunately, the function won't do this and might start the new line in the middle of a word."]
Out[4]=

To work around this, one can simply insert their own line breaks as needed:

In[5]:=
ResourceFunction[
 "RainbowText"]["How wonderful, now I can write a long text in rainbow colors and don't have to worry about\n my words being cut in half."]
Out[5]=

Neat Examples (3) 

In honor of June:

In[6]:=
ResourceFunction["BirdSay"][
 ResourceFunction["RainbowText"]["Happy Pride Month!"]]
Out[6]=

In honor of the biblical creation story of rainbows:

In[7]:=
ResourceFunction[
 "RainbowText"]["13 I have set my rainbow in the clouds, and it will be the sign of the covenant between me and the earth. \n14 Whenever I bring clouds over the earth and the rainbow appears in the clouds, \n15 I will remember my covenant between me and you and all living creatures of every kind. \n Never again will the waters become a flood to destroy all life. \n 16 Whenever the rainbow appears in the clouds, I will see it and remember the everlasting \ncovenant between God and all living creatures of every kind on the earth.\n \t \t Genesis 9:13-16"]
Out[7]=

Rainbow-colored science is fun!

In[8]:=
ResourceFunction[
 "RainbowText"]["A rainbow is an excellent demonstration of the dispersion of light and one more piece of evidence \n that visible light is composed of a spectrum of wavelengths, each associated with a distinct \n color. To view a rainbow, your back must be to the sun as you look at an approximately 40 \n degree angle above the ground into a region of the atmosphere with suspended droplets of \n water or even a light mist. Each individual droplet of water acts as a tiny prism that both \n disperses the light and reflects it back to your eye.\n \t \t physicsclassroom.com"]
Out[8]=

Version History

  • 1.0.0 – 30 July 2019

Related Resources

License Information