Differences

This shows you the differences between two versions of the page.

scripts:building [2012/05/23 02:04]
koira created
scripts:building [2012/05/24 03:54] (current)
koira
Line 65: Line 65:
 close($desc); close($desc);
 </file> </file>
 +
 +===== Add Rainbow Gradient to Lines =====
 +This script will take a file with a single line and cycle through the rainbow on each character.
 +<file perl grainbow.pl>
 +#!/usr/bin/perl
 +# script to rainbow-ize using Medieval Times MUD ansi codes
 +# written by Koira on May 23nd, 2012
 +
 +my $usage = "Usage: ./rainbow.pl file\n
 +Make sure file only has one line\n";
 +die($usage) if (@ARGV != 1);
 +
 +
 +# open file and format input
 +open(my $desc,"<","$ARGV[0]") or die "Could not open description file.\n";
 +my $line = <$desc>;
 +chomp($line);
 +
 +# setup array
 +my @chars;
 +@chars = split(//,$line);
 +my $length = @chars;
 +my $newline;
 +my $n=0;
 +
 +# color elements in array
 +while($n < $length){
 +  $newline .= "&+R$chars[$n]";
 +  $newline .= "&+r$chars[$n+1]";
 +  $newline .= "&+y$chars[$n+2]";
 +  $newline .= "&+Y$chars[$n+3]";
 +  $newline .= "&+G$chars[$n+4]";
 +  $newline .= "&+g$chars[$n+5]";
 +  $newline .= "&+b$chars[$n+6]";
 +  $newline .= "&+B$chars[$n+7]";
 +  $newline .= "&+C$chars[$n+8]";
 +  $newline .= "&+c$chars[$n+9]";
 +  $newline .= "&+m$chars[$n+10]";
 +  $newline .= "&+M$chars[$n+11]";
 +  $n = $n + 12;
 +}
 +
 +# print result and close
 +print $newline, "&N\n";
 +close($desc);
 +</file>
 +
scripts/building.txt · Last modified: 2012/05/24 03:54 by koira
Firefox 3