$mcolor - Text in random color

By Scakk on Sep 17, 2008

This alias will return the text in random color per letter or random color per letter with a random color back ground per letter. Background color is optional.

Usage: $mcolor(TEXT) = text in random color ( each leter a different color )
//echo -ag $mcolor(color text test)
Usage: $mcolor(TEXT).b = text in random color with different background color ( each leter a different color )
//echo -ag $mcolor(test text color).b

Update: 17Sep08 Will not use same text color and background color.
Update: 17Sep08 Issue where using numbers caused errors has been fixed.

/*
Usage: $mcolor(TEXT) = text in random color ( each leter a different color )
//echo -ag $mcolor(color text test)
Usage: $mcolor(TEXT).b = text in random color with different background color ( each leter a different color )
//echo -ag $mcolor(test text color).b
*/

alias mcolor {
  if ($isid && $1) {
    var %z 1, %c
    var %t $replace($1-,$chr(32),$chr(17))
    while (%z <= $len($1-)) { 
      :retry
      var %a $r(0,15), %b $r(0,15)
      if (%a == %b) { goto retry }
      %c = %c $+ $iif($prop == b,$+($chr(3),$iif($len(%a) = 1,$+($chr(48),%a),%a),$chr(44),$iif($len(%b) = 1,$+($chr(48),%b),%b)),$+($chr(3),$iif($len(%b) = 1,$+($chr(48),%b),%b))) $+ $mid(%t,%z,1) $+ $chr(3) 
      inc %z 
    }
    return $replace(%c,$chr(17),$+($chr(3),$chr(48),$chr(44),$chr(48),$chr(32),$chr(3))) 
  } 
}

Comments

Sign in to comment.
Scakk   -  Jan 06, 2011

I fixed the issue you mentioned as if you have text after it will keep the last color for the entire line.

 Respond  
Alpha Atom   -  Jan 06, 2011

-ignore this I misunderstood-

 Respond  
Jonesy44   -  Mar 13, 2009
//echo -a $mcolor(text)[.b]

//echo -a: echos the text in the active window (-a means active trigger)
$mcolor: the identifier
text: the first paramater, the text to be colored
.b: optional background ..option

Nice work.

 Respond  
keither725   -  Mar 12, 2009

i dont get how to do it...

 Respond  
Scakk   -  Sep 17, 2008

Update: 17Sep08 Issue where using numbers caused errors has been fixed.

 Respond  
rhasttaff   -  Sep 17, 2008

hello again!!!
to me works but cannot contain numbers

Jah Bless´´´

 Respond  
Scakk   -  Sep 17, 2008

Update: 17Sep08 Will not use same text color and background color.

 Respond  
napalm`   -  Sep 17, 2008

Fixed.

 Respond  
Scakk   -  Sep 17, 2008

I will working on a way to fix that. Once I get it I will post.

napalm - Your version removes spaces between words.

 Respond  
napalm`   -  Sep 17, 2008
alias mcolor {
  var %w 1 , %x , %y , %z
  while (%w <= $len($1-)) { :redo
    %y = $r(2,15) | %z = $r(2,15)
    if (%y == %z) goto redo
    %x = %x $+ $iif($prop == b,$+($chr(15),$chr(3),%y,$chr(44),%z),$+($chr(3),%z)) $+ $mid($replace($1-,$chr(32),$chr(1)),%w,1)
    inc %w
  }
  return $replace(%x,$chr(1),$chr(32))
}
 Respond  
napalm`   -  Sep 17, 2008

Need to fix the problem with text being the same color as the background, thus making it invisible.

 Respond  
rhasttaff   -  Sep 17, 2008

Very good man!! Nice work Scakk
and i like your $identifiers ideas
keep it up!!

Jah Bless´´´

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.