PDA

View Full Version : New BB tag to do rainbow text...


Zzed
08 Jan 2003, 19:48
This is a fairly simple hack that allows you to create a new BB tag to do
rainbow colors with text. It is only a few lines and the only file affected
by it is admin/functions.php.

You can see a sample output in this thread: http://www.ls1.com/forums/showthread.php?s=&threadid=225576


Note1: This hack has been done and tested on VB 2.2.9
Note2: Using other BB tags within the rainbow tags will convert the underlying HTML code in to rainbow text. :D

Note3: You can find the revised and BB code friendly version in this post (http://www.vbulletin.org/forum/showthread.php?postid=340386#post340386)

Note4: You can find the version that displays the full spectrum of colors in this post (http://www.vbulletin.org/forum/showthread.php?postid=342116#post342116).

Chris M
08 Jan 2003, 20:19
Looks good;)

Satan

Floris
08 Jan 2003, 20:41
Please add your hack in a .txt file rather then showing it like this. Thank you.

DrkFusion
08 Jan 2003, 21:59
Hehe cool little hack :)

Drkfusion will install this

vdinh
08 Jan 2003, 22:52
Cool hack :) ... However, I have some problem with some unicode characters. They will show as #xxxx, not as the real unicode charaters. Would you please point out what should I do ?

bitbender
09 Jan 2003, 04:14
/me *clicks install* - clean as a whistle on my 2.2.6 :)

Zzed
09 Jan 2003, 05:39
Originally posted by vdinh
Cool hack :) ... However, I have some problem with some unicode characters. They will show as #xxxx, not as the real unicode charaters. Would you please point out what should I do ?

I wonder if you can point me to a thread in your forums so that I can see what you are seeing. :)

Boofo
09 Jan 2003, 07:23
Zzed, I figured out how to take the black background out but how do I make the rainbow text the same size that is set for the message? It is bigger than the regular message text.

Great hack, by the way. :)

Zzed
09 Jan 2003, 07:52
Originally posted by Boofo
Zzed, I figured out how to take the black background out but how do I make the rainbow text the same size that is set for the message? It is bigger than the regular message text.

Great hack, by the way. :)

Thank you Boofo. :)

Here is how you fix the font size. ;)

Change this line in dorainbow()


$buffer .= "<font color=\"$color\">";


To this:


$buffer .= "<font color=\"$color\" face=\"verdana,arial,helvetica\" size=\"2\">";

Boofo
09 Jan 2003, 08:04
That was quick. Thank you. :)

Here is what I changed to make the background transparent.

$buffer = "<table><tr><td bgcolor=\"\">";

It works, but is it the correct way to do it? :)

corsacrazy
09 Jan 2003, 08:39
is there a way to add this using the bb code adding option in the acp or do i have to edit my functions :(

Zzed
09 Jan 2003, 08:40
Boofo, You can actually leave out the bgcolor stuff and just use <td> by itself. ;)

corsacrazy, unfortunately to the best of my knowledge this is the only way to do it. :(

corsacrazy
09 Jan 2003, 08:48
Originally posted by Zzed
corsacrazy, unfortunately to the best of my knowledge this is the only way to do it. :(

k cheeres ! ill give it a go !

Boofo
09 Jan 2003, 09:16
Originally posted by Zzed
Boofo, You can actually leave out the bgcolor stuff and just use <td> by itself. ;)


DOHH!!! :) I figured that out after I wrote the message. Sorry about that. The size change works great but I can not change the size of the text to anything else within the message now for some reason. :(

sphinx
09 Jan 2003, 10:33
very nice m8

bitbender
09 Jan 2003, 15:04
Here is one example...

User name to log with: bit_user2
password: testme

Link to Thread in question (http://www.bitbenderforums.com/vb22/showthread.php?postid=226199#post226199)

Zzed
09 Jan 2003, 16:18
Originally posted by bitbender
Here is one example...

User name to log with: bit_user2
password: testme

Link to Thread in question (http://www.bitbenderforums.com/vb22/showthread.php?postid=226199#post226199)

Ok, I assume you are talking about post #2 in that thread. I made a note in my original post that using BB code inside the rainbow tags will end up displaying the underlying HTML code, which is what you are seeing in there.

I can probably fix it. But it is not something that I can do any time soon. :(

nymyth
09 Jan 2003, 17:25
i installed this hack, but i dont see anything.......whats going on??

Peace

ps..i mean is there supposed to be an option that u press like php/list etc??

Silenced Soul
09 Jan 2003, 17:44
heh, pretty cool. I'll install it just for fun. :P

bitbender
09 Jan 2003, 17:48
I can probably fix it. But it is not something that I can do any time soon

Ok, I understand.. I wondered if I read past it before.... and I did..sorry.

nymyth
09 Jan 2003, 17:49
well the code works....when i put in [ rainbow]text here[ /rainbow]


my question is do i have to do this manually each time....????or is there a drop down menu im missing??

Peace

KuraFire
09 Jan 2003, 17:52
oh god....

*winces*

What a lovely idea.. make the sourcecode of already huge threads even twice as big! :up:

Use five hundred font tags in a page! :up:

Double your bandwidth usages if people use your lovely (</sc>) hack! :up::up:

ugh...
(sorry, just felt like pointing that out ^_^)

Areku
09 Jan 2003, 21:10
Originally posted by DrkFusion
Hehe cool little hack :)

Drkfusion will install this

Can you, DarkFusion, or anyone, explain me how to get the rainbow to act like HERE and not like the original hack? the original hack is lack of green and blueish colors of the rainbow...

Tu!

Zzed
09 Jan 2003, 21:17
Ok, here is the BB code friendly version. ;)

Note: If you have installed the original version, you need to back out of it and replace it with this one.

John
09 Jan 2003, 21:46
I made a couple of changes to this - I didn't much like the black background, so I went for the dark glow option. (See attached screenshot)

John
09 Jan 2003, 21:48
To use glow like I did, simply modify the code from the hack in the first post:

Find (in functions.php):


// ###################### Startdorainbow #######################
function dorainbow($code) {
$len = strlen($code);
$buffer = "<table><tr><td bgcolor=\"#000000\">";
$mul = 255/$len;
for($x = 0;$x < $len;$x++) {
$color_h1 = 255*sin($x/($len/3));
$color_h2 = $mul * $x;
$color = sprintf("#FF%02X%02X", $color_h1, $color_h2);
$buffer .= "<font color=\"$color\">";
$buffer .= substr($code,$x,1);
$buffer .= "</font>";
}
$buffer .= "</td></tr></table>";

return($buffer);
}


And replace with:


// ###################### Startdorainbow #######################
function dorainbow($code) {
$len = strlen($code);
$buffer = "<table style=\"filter:glow(color=black, strength=2)\"><tr><td>";
$mul = 255/$len;
for($x = 0;$x < $len;$x++) {
$color_h1 = 255*sin($x/($len/3));
$color_h2 = $mul * $x;
$color = sprintf("#FF%02X%02X", $color_h1, $color_h2);
$buffer .= "<font color=\"$color\" face=\"Verdana\" size=2><b>";
$buffer .= substr($code,$x,1);
$buffer .= "</b></font>";
}
$buffer .= "</td></tr></table>";

return($buffer);
}

Areku
09 Jan 2003, 21:51
FAR FAR Much nicer now with the glow effect!

However how do i add the FULL range of colors and not just the red/yellow/pink ones?

Blue and green are missing from the spectrum!!

John
09 Jan 2003, 21:53
Originally posted by Areku
FAR FAR Much nicer now with the glow effect!

However how do i add the FULL range of colors and not just the red/yellow/pink ones?

Blue and green are missing from the spectrum!!

No idea!

This code is pretty clever stuff, I can't figure it out!

Areku
09 Jan 2003, 21:55
What a weirdo!

Full range of colors is active here!!

supercalifragilisticumspialidociousisthewordiusetotestthisrainbowthing

Areku
09 Jan 2003, 21:56
Oh!

It didn't work!!

DarkFusion, what did u use!? Manually entered that sentence colorfull?

John
09 Jan 2003, 22:00
Yes, he did (try quoting his post!)

Areku
09 Jan 2003, 22:02
I did quote his, still stunned he spent that much time!!

However there must be a way to add blue and green to the rainbow of this hack, isn't it??

John
09 Jan 2003, 22:03
There's always a way, but the maths would be more complicated.

Zzed
09 Jan 2003, 22:07
Guys, please also check out this post for the BB code friendly version ;)

http://www.vbulletin.org/forum/showthread.php?postid=340386#post340386

DrkFusion
09 Jan 2003, 22:16
supercalifragilisticumspialidociousisthewordiusetotestthisrainbowthing
Also jsut a reminder to people you will use J.Eovies mod, keep in mind that the glow style can be viewed by users using IE 5.5+ I am not sure about other browsers.

By the way its a secret :speechless:

Areku
09 Jan 2003, 22:21
So how many $$$ to reveal your trick Dfusion? ;)

Zzed
09 Jan 2003, 22:22
Originally posted by DrkFusion
supercalifragilisticumspialidociousisthewordiusetotestthisrainbowthing
Also jsut a reminder to people you will use J.Eovies mod, keep in mind that the glow style can be viewed by users using IE 5.5+ I am not sure about other browsers.

By the way its a secret :speechless:

You my friend are a mean person. :D j/k ;)

DrkFusion
09 Jan 2003, 22:42
By me a HiveMail Liscense :P and I will reveal to you LOL

Areku
10 Jan 2003, 12:22
U're too xpensive! ;)

Boofo
10 Jan 2003, 12:25
Originally posted by DrkFusion
By me a HiveMail Liscense :P and I will reveal to you LOL

As one of the Kirby brothers you could reveal it to me in a pm. ;)

Boofo
10 Jan 2003, 15:32
Originally posted by Zzed
Ok, here is the BB code friendly version. ;)

Note: If you have installed the original version, you need to back out of it and replace it with this one.

I installed this and the only vbcode it would recognize and use was the FONT code. The size and nothing else works with it. What is the difference between this version and the first version you posted? And is there a way to get the whole color spectrum (like in Drks replies)? Also, is there a way to have it default to the board set font size instead of having to hard code it to size 2?

John
10 Jan 2003, 15:38
I found a bit of a flaw in this - when you type in a lot of text, you can see the backslashes for " cancelling and line breaks:

http://www.eovie.com/problem.gif

flup
11 Jan 2003, 12:13
Nice, won't install it though ;)

Barret
14 Jan 2003, 04:52
I might install it, thanks!

Zzed
14 Jan 2003, 07:04
I went ahead and made a new version that looks like DrkFusion's posts. Here is an example. I will release it in this thread for anyone who is interested.

http://www.ls1.com/forums/showthread.php?postid=2190859#post2190859

Boofo
14 Jan 2003, 08:23
I'm interested. Send it up, sir. :)

Will they still make the rainbow wider as you add more text or will it start the rainbow effect over again after so much text? The second option would actually be better, if it can be done, that is. :)

nymyth
14 Jan 2003, 08:24
im interested...how can i get it...thanx

Peace

Zzed
14 Jan 2003, 08:32
Originally posted by Boofo
I'm interested. Send it up, sir. :)

Will they still make the rainbow wider as you add more text or will it start the rainbow effect over again after so much text? The second option would actually be better, if it can be done, that is. :)

It widens as your text gets longer. ;)

I will release the hack. :)

KuraFire
14 Jan 2003, 09:11
omg I'm glad I use Mozilla...

glows... evil... *shudders*

I totally forgot how horrible those look...

Areku
14 Jan 2003, 16:38
SO, where is it?!?!

Barret
14 Jan 2003, 19:54
Zzed,
We are waiting man. Glad you are helping with this.
Thanks in advance.

Zzed
14 Jan 2003, 21:42
Here is the version with the full spectrum of colors.

This is what the output of the tag looks like: http://www.ls1.com/forums/showthread.php?postid=2190859#post2190859

Enjoy :D

Barret
14 Jan 2003, 22:19
Zzed,
You are the greatest and I am pleased to be the first to thank you.
Thanks! :)
Clicks install

{{UPDATE}} This hack also is fixed from the previous version where there were a few problems as posted by john.eovie
Here (http://www.vbulletin.org/forum/showthread.php?s=&threadid=47509&perpage=15&display=&pagenumber=3)

Zzed
14 Jan 2003, 22:49
Originally posted by Barret
Zzed,
You are the greatest and I am pleased to be the first to thank you.
Thanks! :)
Clicks install

{{UPDATE}} This hack also is fixed from the previous version where there were a few problems as posted by john.eovie
Here (http://www.vbulletin.org/forum/showthread.php?s=&threadid=47509&perpage=15&display=&pagenumber=3)

Thank you for your kind words. https://www.vbulletin.org/forum/

Boofo
14 Jan 2003, 23:03
Zzed, I couldn't do the new version with the following line:

$bbcode=str_replace("{", "{", $bbcode); // stop people posting replacements in their posts

Because my line for that is this:

// $bbcode=str_replace("{", "{", $bbcode); // stop people posting replacements in their posts

because of another hack. I just changed the "// ###################### Startdorainbow #######################" part and left the first part from version 1 in there instead. It seems to work. ;)

XIanX
14 Jan 2003, 23:11
Originally posted by Zzed
I went ahead and made a new version that looks like DrkFusion's posts. Here is an example. I will release it in this thread for anyone who is interested.I'm interested. :)

Zzed
14 Jan 2003, 23:12
Originally posted by XIanX
I'm interested. :)

LOL, Look at Post #52 (http://www.vbulletin.org/forum/showthread.php?postid=342116#post342116) in this thread. :D

Jack of Xanadu
18 Jan 2003, 00:19
I did some fine tweaking on the scripts and merged both scripts a little and now it looks awsome:
You can see it in action in here (http://www.fox-community.com/forums/showthread.php?s=&threadid=4656&pagenumber=2)
original script:

// ###################### Startdorainbow #######################
function dorainbow($code) {
$textlen = 0;
$tag = 0;
$len = strlen($code);

for($x = 0;$x < $len;$x++) {
if(substr($code,$x,1) == "\\") {
continue;
}
if($tag == 0) {
if(substr($code,$x,1) == "<") {
$tag = 1;
}
else {
$textlen++;
}
}
else {
if(substr($code,$x,1) == ">") {
$tag = 0;
}
}
}

$buffer = "<table><tr><td bgcolor=\"#000000\">";
$slice = $textlen / 6;
$step = 255 / $slice;
$index = 0;
$R = 255;
$G = 0;
$B = 0;
$section = 0;
$count = 0;
for($x = 0;$x < $len;$x++) {
if(substr($code,$x,1) == "\\") {
continue;
}
if($tag == 0) {
if(substr($code,$x,1) == "<") {
$buffer .= substr($code,$x,1);
$tag = 1;
}
else {
if($section == 0) {
$Rx = 0;
$Gx = $step;
$Bx = 0;
} else if ($section == 1) {
$Rx = (-1) * $step;
$Gx = 0;
$Bx = 0;
} else if ($section == 2) {
$Rx = 0;
$Gx = 0;
$Bx = $step;
} else if ($section == 3) {
$Rx = 0;
$Gx = (-1) * $step;
$Bx = 0;
} else if ($section == 4) {
$Rx = $step;
$Gx = 0;
$Bx = $step;
} else {
$Rx = 0;
$Gx = 0;
$Bx = (-1) * $step;
}
$count++;
if($count > $slice) {
$section++;
$count = 0;
}
$R += $Rx;
$G += $Gx;
$B += $Bx;
$R = iif($R > 255, 255, $R);
$R = iif($R < 0, 0, $R);
$G = iif($G > 255, 255, $G);
$G = iif($G < 0, 0, $G);
$B = iif($B > 255, 255, $B);
$B = iif($B < 0, 0, $B);
$color = sprintf("#%02X%02X%02X", $R, $G, $B);
$buffer .= "<font color=\"$color\">";
$buffer .= substr($code,$x,1);
$buffer .= "</font>";
$index++;
}
}
else {
if(substr($code,$x,1) == ">") {
$tag = 0;
}
$buffer .= substr($code,$x,1);
}
}
$buffer .= "</td></tr></table>";

return($buffer);
}

Replace it with:

// ###################### Startdorainbow #######################
function dorainbow($code) {
$textlen = 0;
$tag = 0;
$len = strlen($code);

for($x = 0;$x < $len;$x++) {
if(substr($code,$x,1) == "\\") {
continue;
}
if($tag == 0) {
if(substr($code,$x,1) == "<") {
$tag = 1;
}
else {
$textlen++;
}
}
else {
if(substr($code,$x,1) == ">") {
$tag = 0;
}
}
}

$buffer = "<table style=\"filter:glow(color=black, strength=6)\"><tr><td>";
$slice = $textlen / 6;
$step = 255 / $slice;
$index = 0;
$R = 255;
$G = 0;
$B = 0;
$section = 0;
$count = 0;
for($x = 0;$x < $len;$x++) {
if(substr($code,$x,1) == "\\") {
continue;
}
if($tag == 0) {
if(substr($code,$x,1) == "<") {
$buffer .= substr($code,$x,1);
$tag = 1;
}
else {
if($section == 0) {
$Rx = 0;
$Gx = $step;
$Bx = 0;
} else if ($section == 1) {
$Rx = (-1) * $step;
$Gx = 0;
$Bx = 0;
} else if ($section == 2) {
$Rx = 0;
$Gx = 0;
$Bx = $step;
} else if ($section == 3) {
$Rx = 0;
$Gx = (-1) * $step;
$Bx = 0;
} else if ($section == 4) {
$Rx = $step;
$Gx = 0;
$Bx = $step;
} else {
$Rx = 0;
$Gx = 0;
$Bx = (-1) * $step;
}
$count++;
if($count > $slice) {
$section++;
$count = 0;
}
$R += $Rx;
$G += $Gx;
$B += $Bx;
$R = iif($R > 255, 255, $R);
$R = iif($R < 0, 0, $R);
$G = iif($G > 255, 255, $G);
$G = iif($G < 0, 0, $G);
$B = iif($B > 255, 255, $B);
$B = iif($B < 0, 0, $B);
$color = sprintf("#%02X%02X%02X", $R, $G, $B);
$buffer .= "<font color=\"$color\" face=\"Verdana\" size=2><b>";
$buffer .= substr($code,$x,1);
$buffer .= "</font>";
$index++;
}
}
else {
if(substr($code,$x,1) == ">") {
$tag = 0;
}
$buffer .= substr($code,$x,1);
}
}
$buffer .= "</td></tr></table>";

return($buffer);
}

Boofo
18 Jan 2003, 08:51
LOL That was already done (with a little less glow effect, which looks better) in the beginning of the thread. What else was changed, maybe I missed it?

Areku
18 Jan 2003, 11:21
The one with glow effect at the beginning of the thread was NOT having the full spectrum of colours ;)

Thanks Jack! ;)

Robink
07 Feb 2003, 07:28
I always get the error "Division by zero" :(

Robink
07 Feb 2003, 07:29
In particular it sayd this:

Warning: Division by zero in /home/virtual/site13/fst/var/www/html/forums/admin/functions.php on line 844


I tried both versions of the hack :(

Classy
07 Apr 2003, 00:31
Nice addition :D Installed and works on 2.3.0
Clicked install :D Thank you

Zzed
07 Apr 2003, 07:34
02-07-03 at 01:29 AM Robink said this in Post #62 (http://www.vbulletin.org/forum/showthread.php?postid=351385#post351385)
In particular it sayd this:

Warning: Division by zero in /home/virtual/site13/fst/var/www/html/forums/admin/functions.php on line 844


I tried both versions of the hack :(

Please Email me a copy of your functions.php.

My Email is: edwink@seebeyond.com

MooMan65
30 Apr 2003, 03:52
I get a division by zero error every time someone types in without anything in it. The error only appears on the page at which it's typed but doesn't go away, it just accumulates over time. Otherwise the hack works perfectly, but it's that error which is stopping me from installing it, as not all members are kind enough to NOT type it in. :( And way to stop this?

Zzed
30 Apr 2003, 05:31
I will correct the bug and post a fix. I'll do that later tonight.

Zzed
30 Apr 2003, 09:48
I have fixed all the attached versions for the "division by zero" error. ;)

Boofo
30 Apr 2003, 09:53
Today at 04:48 AM Zzed said this in Post #67 (http://www.vbulletin.org/forum/showthread.php?postid=389298#post389298)
I have fixed all the attached versions for the "division by zero" error. ;)

I'm still using version 1 with the code in the functions.php. What would be the fix for that?

Zzed
30 Apr 2003, 10:16
I fixed all 3 versions. ;)

In function dorainbow()
Look for:

$len = strlen($code);


Add this directly below it:

if($len == 0) {
return($code);
}

lioncool1589
09 Sep 2003, 00:46
would be nice if user can change diff color

Zachery
13 Mar 2004, 07:25
would be nice if user can change diff color
Wow old, but Zzed will you be making an updated version to vB3?

rebelsrock06
21 Mar 2004, 00:52
Wow old, but Zzed will you be making an updated version to vB3?
id really really love to have this for VB3

Ill beg if i have to

sabret00the
08 May 2004, 15:10
me too :)

msimplay
08 May 2004, 15:13
me 3
LMAO I always end up in the wanting the same things as Sabertoothe :p

sabret00the
03 Jun 2004, 17:32
*bump*