Page 1 of 1

Virtual BBCode

Posted: Wed Nov 23, 2011 1:45 am
by VirtLands
For fun, I decided to expand the BBCODE possibilities,
even though this is currently make-believe.

'Virtual BBCode' is an idea I invented to describe
a set of commands or combinations that don't yet exist,
or that are impossible.

Someone can design a program that
would read in anomalous BBCode from a text file.
Then this program would 'translate' that code into
equivalent code that really works for this forum.

So, for example, the user types in the extended BBCODE into a text file (.TXT);
then the special program reads the text file, and creates a new output text file,
which can then be pasted to forum posts.


Some popular examples of anomalous (irregular) code:

Line 1:Image [color=blue]..text A..[color=red]..text B..[/color]..text C..[color=cyan]..text D..[/color]..text E..[/color]
Line 2:Image [color=red]..text F..[b]..text G..[/color]..text H..[/b]
Line 3:Image [size=9]..text I..[size=12]..text J..[/size]..text K..[/size]
Line 4:Image [b]..text L..[b]..text M..[/b]..text N..[/b]
Line 5:Image [b]..text O..[unbold]..text P..[/unbold]..text Q..[/b]
Line 6:Image [u]..text R..[i]..text S..[b]..text T..[/i]..text U..[/u]..text V..[/b]..text V2..
Line 7:Image [size=10]..text W..[size=11]..text X..[size=12]..text Y..[/size]..text Z..[/size]..text Z2..[/size]
Line 8:Image [size=18][color=#784522][b]..text A1..[/size][/color][/b]

The correct output should be:
( I let the BBcodes appear for here for demonstrations purposes, so that your eye can follow the logic. )

Line 1:Image [color=blue]..text A..[color=red]..text B..[/color]..text C..[color=cyan]..text D..[/color]..text E..[/color]
Line 2:Image [color=red]..text F..[b]..text G..[/color]..text H..[/b]
Line 3:Image [size=9]..text I..[size=12]..text J..[/size]..text K..[/size]
Line 4:Image [b]..text L..[b]..text M..[/b]..text N..[/b]
Line 5:Image [b]..text O..[unbold]..text P..[/unbold]..text Q..[/b]
Line 6:Image [u]..text R..[i]..text S..[b]..text T..[/i]..text U..[/u]..text V..[/b]..text V2..
Line 7:Image [size=10]..text W..[size=11]..text X..[size=12]..text Y..[/size]..text Z..[/size]..text Z2..[/size]
Line 8:Image [size=18][color=#784522][b]..text A1..[/size][/color][/b]

My comments:

Image In general, all commands should be able to be nested.
Image In the case of Line 1, every time that a color function is encountered, the previous color (if any)
Image is 'saved' in memory (remaining dormant), and is activated again when the current
Image color encounters its termination command, [/color] .
Image The logic here would involve using memory stacks for many BBCode functions, using LIFO logic, (last in, first out).
Image
Image In the case of Lines 2 and 6, it shouldn't matter what order the [color=], [u], [i], [b] is in.
Image All that matters is that the statement is eventually balanced with an equal number of [color=], [u], [i], [b]
Image towards the right side.


In reality, Lines 1 to 8 show up as follows: (not the way it should)

Line 1:Image ..text A....text B....text C....text D....text E..
Line 2:Image ..text F....text G....text H..
Line 3:Image ..text I....text J....text K..
Line 4:Image ..text L....text M....text N..
Line 5:Image ..text O..[unbold]..text P..[/unbold]..text Q..
Line 6:Image ..text R....text S....text T....text U....text V..
Line 7:Image ..text W....text X....text Y....text Z....text Z2..
Line 8:Image ..text A1.. (Line 8 is an exception and behaves properly. )

-----------------------------------------------------------------------

Some potential BBcode additions:

Image ; set a variable A with RGB color values. Variable 'A' can be assumed to be a special type with 3 fields.
Image setColormem(A,"RGB", 101010, 223344, 440033);

Image ; set a variable B with HSV color values.
Image setColormem(B,"HSV", 101010, 223344, 440033);

Image ; set a variable C with a hex color value.
Image setColormem(C,"hex", #55AA44);

Image ;
Image ; RGB and HSV are some of the different methods to describe colors,
Image ; each method of computing color values has its own +'s and -'s
Image ; HSV = (hue, saturation, value),
Image ; RGB = (red, green, blue)
Image ; It's rather easy to transform between RGB, HSV, and hex.

Image ; References:
Image ; http://web.forret.com/tools/color.asp
Image ; http://en.wikipedia.org/wiki/HSL_and_HSV


Image ; The following fictional command would graduate the colors across a statement,
Image ; starting with color variable 'A' and ending with color variable 'B'
Image ; In other words, each letter would gradually change in color according to its
Image ; position, the optional "HSV" or "RGB" variable would tell which computation method
Image ; to use:

Image [colorspan=A,B,"HSV"]...Toto, I don't think we're in wonderland anymore!...[/colorspan]

Image ; It would be painful to type and compute [color=######]x[/color] statements
Image ; for a collection of 30+ letters (& words), so an automatic function like
Image ; [colorspan=...] could be a great idea.

Image ;
Image ; If anyone can think of some irregular code that I missed,
Image ; or they've got ideas for new BBCode functions, then list them here.

Image ;
Image ; Please note that if you quote this, that it will dramatically alter the formatting.
Image ; To show demonstration BBCode that does not become active, you can use a Unicode bracket, [ = [ .

Posted: Wed Nov 23, 2011 2:30 am
by maxnick
Great, I especially like the "Colorspan" idea.

I have some ideas to expand on that:

[colorspan=#FFFFFF, #FF0000, "RBG", 3]Text here.[/colorspan]

Here, I used an extra variable that adjusted the "speed" of the trasition between the two colors, if you don't list any value here, the default is the length of the text. The code above would apear as:

Text here.

Therefore, with a transition speed of 2, you could easily make stripes:

[colorspan=#0000FF,#FF0000, "RGB", 2]Text here.[/colorspan]

Text here.

As this might be complicated to casual users of BBCode, you could even have it so saying "2" is not necessary and you could say "stripes" instead:

So:

[colorspan=#00FF00,#FF0000, "RGB", "stripes"]Text here.[/colorspan]

Would work fine too.

Anyway yeah those are my ideas, feel free to give constructive criticism.

maxnick's idea on BBCode [colorspan=..]

Posted: Wed Nov 23, 2011 3:11 am
by VirtLands
maxnick wrote:Here, I used an extra variable that adjusted the "speed" of the trasition between the two colors, if you don't list any value here, the default is the length of the text. The code above would apear as:

Text here.

Therefore, with a transition speed of 2, you could easily make stripes:

[colorspan=#00FF00,#FF0000, "RGB", 2]Text here.[/colorspan]
Wow, that is sharp, and I suppose that by speed that you mean
'intermediate steps' of color between the Start_Color and Finish_Color.
If the 'intermediate steps' are less than the number of letters in the
statement then you could see a stripes effect.

The stripes option creates the obvious repeating color effect, which looks
really nice, as you demonstrated.

Another neat function could be

[LetterColors=A,B, "rgb"]...text here...[/letterColors]

In this case each letter assumes a color defined by its identity,
(not its position), So, the letter 'A' will take on the Start_Color,
letter 'Z' will take on the Finish_Color, and the letters in between
shall get graduated (or interpolated) values between A..Z, or a..z

----
Of course, if any software came into existence for these tasks, it would take a lot of math, parsing, programming, so, it's just an idea for now.

Posted: Wed Nov 23, 2011 3:41 am
by maxnick
Nice. :)

I thought that it might be a good idea, even though it may cause problems, to have:

setColorspanmem(A, "RGB", "hex", #FF0000, #00FF00)

Of course, this is a little complicated becuase it would require 2 potentially different kinds of color systems, one for writing the colors themselves, and one for computing the values between the colors.

Speaking of color systems, it seems odd to me that a CMYK color option is not included, however, it might be kinda pointless, because CMYK dosen't even include all the colors that RGB does, but sense this is just imaginary, I don't see any reason it couldn't be included.

Anyway, back to the gradients, the advantage of the "setColorspanmem" is that it opens up the possibility for more complex gradients, like in Photoshop, represented with something like:

setColorspanmem(A, "RGB", "hex", 33, #FF0000, 66, #00FF00, 100, #0000FF)

Which would make a gradient that starts off red, then turns blue, then goes to green.

With this way of defining gradients, you can have up to 100 colors at different spots, one problem is that you can't equally divide things into thirds this way, so if you had:

setColorspanmem(A, "RGB", "hex", 33, #FF0000, 67, #00FF00, 100, #0000FF)

[colorspan=A, 3]Text here.[/colorspan]

Which would seem to be:

Text here.

It would actually have several shades in between colors, as it would try to color the text whatever the shade at 33.33333... would be, which wouldn't be exactly red. In most cases this probably wouldn't matter, but it would make the system awkward to work with if for some reason you wanted a very specific color for a letter.

Posted: Wed Nov 23, 2011 5:27 am
by tyteen4a03
The correct way of wrapping BBcode around a text is [t1][t2][t3]text[/t3][/t2][/t1], not [/t1][/t2][/t3]. Think of it as unwrapping a present.

If you replace BBcode with HTML and use incorrect wrapping it would still work because HTML is tolerant of errors, but in XHTML this is not allowed at all.

Also, about the attributes: It's doable, except we usually use name=value, name=value instead of just value, value, value.

There are many BBcode parsers out there, so adding new BBcodes is easy, provided that you know HTML and maybe PHP.

The code of doing the [rainbow] tag (that's how I call it :P) in PHP would be: (excuse my mistakes, if any):

Code: Select all

$list = explode($text, ""); // Split all the characters into an array like ("t", "e", "x", "t") for easy iteration
$i = 1; // Mark the next colour
$final = ""; // Final string
foreach $list as $element { // Start the for loop
    switch ($i) { // Depends on the variable $i, change colour as we reach the next character
        case 1:
            $final .= "<span style="colour&#58; red;">".$element."</span>";
            $i++; // Move to the next number
        case 2&#58;
            $final .= "<span style="colour&#58; orange;">".$element."</span>";
            $i++; // Move to the next number
        case 3&#58;
            $final .= "<span style="colour&#58; yellow;">".$element."</span>";
            $i++; // Move to the next number
         // Insert more cases here, I will skip these for now
        case 7&#58;
            $final .= "<span style="colour&#58; red;">".$element."</span>";
            $i = 1; // Reset back to red
    &#125;
&#125;
echo&#40;$final&#41;; // Echo out the final string

Posted: Wed Nov 23, 2011 6:09 pm
by maxnick
Right so using the "name=value" method would have things more like:

[colorspan start={color} end={color} method={RBG, HSV} speed={number}]Text here.[/colorspan]

I guess the color variables would be something like this:

[/colormem name={variable name} method={hex, RBG, HSV, CMYK} value={hex color, only used if using hex, otherwise use value1} value1={number} value2={number} value3={number} value4={number, only used if using CMYK}]

Examples:

[/colormem name=A method="RBG" value1=255 value2=0 value3=0]

Which would store red in a variable named A.

[/colormem name=B method="CMYK" value1=1 value2=0 value3=0 value4=1]

Which would make some color in variable B.

Posted: Wed Nov 23, 2011 6:41 pm
by tyteen4a03
maxnick wrote:Right so using the "name=value" method would have things more like:

[colorspan start={color} end={color} method={RBG, HSV} speed={number}]Text here.[/colorspan]

I guess the color variables would be something like this:

[/colormem name={variable name} method={hex, RBG, HSV, CMYK} value={hex color, only used if using hex, otherwise use value1} value1={number} value2={number} value3={number} value4={number, only used if using CMYK}]

Examples:

[/colormem name=A method="RBG" value1=255 value2=0 value3=0]

Which would store red in a variable named A.

[/colormem name=B method="CMYK" value1=1 value2=0 value3=0 value4=1]

Which would make some color in variable B.
Declarations in BBCode? that would end up [colourmem name=B method="CMYK" value1=1 value2=0 value3=0 value4=1 /] (XHTML syntax) but honestly I think there will be too much work for the developers, since BBcode is never meant to be a programming language.

Posted: Wed Nov 23, 2011 8:34 pm
by maxnick
Well this just intended to be a a program that can convert from this BBCode to real BBCode, so really the program would just store the color in a variable as text, and then put that into a text file.

Yes it's BBCode

Posted: Sat Nov 26, 2011 6:43 am
by VirtLands
maxnick wrote:[colorspan start={color} end={color} method={RBG, HSV} speed={number}]Text here.[/colorspan]

I guess the color variables would be something like this:

[/colormem name={variable name} method={hex, RBG, HSV, CMYK} value={hex color, only used if using hex, otherwise use value1} value1={number} value2={number} value3={number} value4={number, only used if using CMYK}]
Those are some great ideas, and in the meantime,

I still have to figure out the differences between
CMYK and HSV, ( because I'm not familiar with CMYK ).

Perhaps someday one of us will come up with an actual program
that does "Virtual BBCode to BBCode" conversions.

A program written in Blitz wouldn't need to follow any strict rules.