MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: colored alphabet for string output


Hi,

myList = {"abcdefg", "hijklmn", "prstuv"};

randomColor[] := ToColor[Hue[Random[]], RGBColor];
colorString[str_String] := Module[{ss},
    ss = Characters[str];
    RowBox[StyleForm[#, FontColor -> randomColor[]] & /@ ss]
    ]

colorString /@ myList // DisplayForm

Regards
  Jens

Curt Fischer wrote:
> 
> Dear Group:
> 
> I have a long list of alphabetic strings.  I would like to ouput this list,
> with each of the letters of the string colored differently.  How could I do
> this?
> 
> For example:
> 
> myList = {"abcdefg","hijklmn","prstuv"};
> 
> myList/.{x_String -> StringReplace[x, "a" -> StyleForm["a", FontColor ->
> Red]]}
> 
> I was thinking to hodgepodge together statements like this, but it doesn't
> work because StringReplace requires objects with head String, and my attempt
> has an object with head StyleForm.
> 
> Any advice?
> 
> --
> Curt Fischer


  • Prev by Date: Re: Precision of output
  • Next by Date: Re: colored alphabet for string output
  • Previous by thread: Re: colored alphabet for string output
  • Next by thread: Re: colored alphabet for string output