Template:ColorString
Uses Lua: |
This template creates one or more color boxes or lines, together by a text string which may contain also wikilinks.
It can be transcluded with Legtab, Leglin, Colorstring, and also by Image generation with the parameter |cb=
- The parameter
|cb=
needs a slash-separated sub-parameter sequence, - the other templates can be provided with either pipe-separated or slash-separated parameters.
The template has either only one unnamed parameter, a string of possible subparameters separated by slashes,
or unnamed parameters separated by pipes; in both cases an unlimited number of (sub)parameters can be specified.
- Subparameters
are either pairs of colorcode and text, or just the colorcodes. Each valid color code (CSS color names, hex triplet, tincture names) can be used.
The text can be also wiki-formatted, e.g. a link.
In any case, the parameter sequence can start with an optional pair of control codes preceding the parameter string;
they are also slash/pipe-separated, e.g. "-/-
", specifying
- the possibility to create a field name, when used within
|other fields 1
or|other fields
- the layout of the color box[es] or color line[s].
The first control code may be (see Igen/cbox)
- "
-
" or missing: default; - "
+
" requesting the generation of a field name - "
e
" only when the second code is "T": an "e" will display a bordered example of the file
The second control code specifies
- a "
- a "
C
" for {{Legend}} but Text "Colors" with parameter pairs, - a "
D
" for {{ColorBox}} with (tincture) parameter pairs, - a "
M
" or "-
" for {{Legend-small}} with parameter pairs, - a "
T
" for template:{{Tbc}} always with parameter pairs, - a "
B
" for {{ColorBox}} with single parameter values "B" is usable for non-standard tinctures - a "
L
" for {{Legend}} with single parameter values, ¹) - a "
S
" for {{Legend-small}} with single parameter values.
- ¹) the "L" possibility exists just for completion – normally a "Legend" without an explaining second value will not be useful.
", "C
", "D
", "-
", "M
", "T
") should contain an URL addressin the second parameter, that is only possible with a parameter list separated by pipes "|"
(otherwise the slashes in the URL address would disturb a slash-separated parameter list).
Whenever possible, the boxes are tooltipped.
In a Legend with parameter pairs ("", "
", "C
", "-
", "M
")
- Legend-lines can be drawn, by just expanding the color value e.g.
#030
to#030 dashed 2px
- a workaround exists for striped and bordered boxes, by an extension of the the first parameter:
- the color value is preceded by a sequence of one character and ")", e.g. "6)" for SVGstripes6.svg:
■ 2 spaces: the CSS code for the line, e.g. "#F00 solid 2px ": |
line
|
■ 3 spaces: the color value is followed by a space and the CSS code for the border, e.g. "#FF0 #F00 2px dotted ": |
bordered legend |
■ 4 spaces: the color value is followed by two spaces and the CSS code for the line, e.g. "#FF0 3px dashed red ": |
line wth background |
- the second parameter, the descriptional text, can be ("", "
=
", "#
", "<
"); then the first parameters color is used: - empty or
=
: the first value will be displayed. #
like=
but when the first value is a color name, its code becomes displayed<
like#
but the code display is teletyped
- the second parameter, the descriptional text, can be ("", "
Examples
[edit]See there an example with many colors. See there examples for Tbc parametrizing.
This parameter string... | ...yields: |
---|---|
#FF0
|
#FF0 |
/B/vert/#396
|
vert#396 |
/D/#BC3F4A/sanguine</small>
|
sanguine |
lime/{{W|green}} /#0f47af/azure /#DA121A/gules /#999/{{Wf|cendrée}} |
azure gules
|
with hex codes (and pipes):-|S|#000|#00f|#F0F|#396
|
#000 #00f #F0F #396
|
with the (full!) tincture names:argent//argent-d//or// azure//carnation//céleste// cendrée//gules//naranja// purpure//sable//tawny//vert //invisible |
argent argent-d or azure carnation céleste cendrée gules naranja purpure sable tawny vert
transparent |
with exotic tincture names/L/brunâtre/murrey/ orange_t/sanguine |
brunâtre murrey orange_t
sanguine |
with the CSS color names:/S/black/silver/maroon/red/ green/lime/olive/yellow/ navy/blue/purple/fuchsia/ teal/aqua/gray/olivedrab/ azure_CSS |
black silver maroon red green lime olive yellow navy blue purple fuchsia teal aqua gray olivedrab azure_CSS
|
with URI addresses and other links|M|Peru|{{W|Peru}} article
|
Peru article crimson
|
striped legend (see the "striped" description) this example with second parameter empty or space |
#000 #900 #369
wmg |
{{Legend-line}}s within a legend table://#DA2/desert/#03C solid 3px /stream/#030 dashed 2px/border /G)#8CF/glacier(precede with two slashes to set the lines width) |
desert stream border
glacier |
{{Legend-line}}s and small legends: |
area 1 line 1 area 2 line 2
|
Bordered Legends:/#F00 #030 dotted 3px/dotted border
|
dotted border solid border
fat border |
An example for same-colored borders:/lime lime solid 1px/
|
lime orchid gules
dark blue |