Module:Color2dec/doc
This is the documentation page for Module:Color2dec
Written a bit complicated, due to my poor LUA knowledge.
This module contains global functions, some functions which can be used either global or local, and local functions.
Global function "tbcgen"
accepts & needs two parameters, a color code and a descriptive text.
- the color code may be a valid hexadecimal color triplet, as e.g."#ABCDEF" or "#80c";
otherwise it is treated with the local/global function "tincture";
- it may also be a valid tincture name, e.g. "céleste" (see examples)
- from the many other color names just the set of CSS colors is valid for conversion;
- when a string not starting with "#" cannot find its hexadecimal representation, an error is raised.
- when the descriptive text starts with e.g. "#" that becomes replaced by its decimal numeric character reference
by the local/global function "decode".
Function "convert"
Converts a hexadecimal string (#rrggbb or #rgb) to a table of three decimal values (see also the dec·hex function of template:D2x).
Function "tincture"
Used also globally by template Igen/cbox
Converts the standard tinctures names to their hexadecimal color codes;
Color codes of six hexadecimal numbers #aabbcc are shortened to #ABC when possible (see also template:D2s).
- when not successful, the conversion of CSS names is tried;
- other values are passed without check as-they-are, which may cause an error
Function "decode"
Used also globally by template Igen/cbox and by other templates (same code as in module Char)
Avoids the wiki problem with # * : ; at the first position
- Global functions:
Global function "tbcgen"
"tbcgen" calls the template Tbc with the 5 parameters needed by that template.
Global function "cstring"
Global init for e.g. ColorString, can split slash-separated params
Global function "colorts"
Testfunction for drawing boxes, used at Template talk:ColorString.
Global function "colortab"
Generates a 16 × 16 × 16 tabla, shown at Module talk:Color2dec