Jump to content
kiror

Rainbowfied text

Recommended Posts

kiror    347

This one may have a very good acceptance between the kinmunity members. The code is written in python3 (the fastest way I implemented it).

To the code:

[spoiler=Code with bug]

#!/usr/bin/python3
# -*- coding: utf-8 -*-

from sys import argv as argv

lbbc=[]

def initListOfColors():
   global lbbc
   lbbc=[]
   for i in range(0,256):
       lbbc+=[[255-i,i,0]]
   for i in range(0,256):
       lbbc+=[[0,255-i,i]]
   lbbc=["{:02x}".format(k[0])+
         "{:02x}".format(k[1])+
         "{:02x}".format(k[2]) for k in lbbc]
   return #len(lbbc)==512

def bbcode_txt_lolcat(text):
   o=""
   traveler=20
   for i in range(len(text)):
       o+="[color=#"+lbbc[(i*traveler)%len(lbbc)]+"]"+text[i]+"[/color]"
   return o

def main():
   if len(argv)!=2:
       print("This program takes only one argument.")
   else:
       initListOfColors()
       txt=argv[1]
       o=bbcode_txt_lolcat(txt)
       print(o)
   return

if __name__=="__main__":
   main()

 

Bugfixed:

#!/usr/bin/python3
# -*- coding: utf-8 -*-

from sys import argv as argv

lbbc=[]

def initListOfColors():
   global lbbc
   lbbc=[]
   for i in range(0,256):
       lbbc+=[[255-i,i,0]]
   for i in range(0,256):
       lbbc+=[[0,255-i,i]]
   for i in range(0,256):
       lbbc+=[[i,0,255-i]]
   lbbc=["{:02x}".format(k[0])+
         "{:02x}".format(k[1])+
         "{:02x}".format(k[2]) for k in lbbc]
   return;
   #len(lbbc)==768


def bbcode_txt_lolcat(text):
   o=""
   traveler=20
   for i in range(len(text)):
       o+="[color=#"+lbbc[(i*traveler)%len(lbbc)]+"]"+text[i]+"[/color]"
   return o

def main():
   if len(argv)!=2:
       print("This program takes only one argument.")
   else:
       initListOfColors()
       txt=argv[1]
       o=bbcode_txt_lolcat(txt)
       print(o)
   return

if __name__=="__main__":
   main()

 

Bugfix in rainbow (before and after):

###################################################

###################################################

 

How I used it via terminal:

user@domain:~/Documents/bbcode/rainbowfy$ python3 rbfy.py "This one may have a very good acceptance between the kinmunity members. The code is written in python3 (the fastest way I implemented it)."

Share this post


Link to post
Share on other sites
Raijun    25

That is pretty impressive. My one and only conceivable gripe with this would be that it's occasionally hard to read against the forum posts' colors. I use the dark skin myself, and the blue range kind of fades out against it.

 

But it's wicked cool regardless. Three and a half thumbs up! (ew)

Share this post


Link to post
Share on other sites
Shiro    434

Considering we already have to discourage the use of excessive coloring for readability in introduction posts and similar, this suggestion isn't going to be implemented.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×