Template:Set colours 2: Difference between revisions

From Wikishire
Jump to navigation Jump to search
RB (talk | contribs)
Created page with "{{#vardefine:hueB1|{{#if:{{{1|}}}|{{colour|{{{1}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB2|{{#if:{{{2|}}}|{{colour|{{{2}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:..."
 
RB (talk | contribs)
mNo edit summary
 
Line 1: Line 1:
{{#vardefine:hueB1|{{#if:{{{1|}}}|{{colour|{{{1}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB2|{{#if:{{{2|}}}|{{colour|{{{2}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB3|{{#if:{{{3|}}}|{{colour|{{{3}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB4|{{#if:{{{4|}}}|{{colour|{{{4}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB5|{{#if:{{{5|}}}|{{colour|{{{5}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB6|{{#if:{{{6|}}}|{{colour|{{{6}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB7|{{#if:{{{7|}}}|{{colour|{{{7}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB8|{{#if:{{{8|}}}|{{colour|{{{8}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB9|{{#if:{{{9|}}}|{{colour|{{{9}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB10|{{#if:{{{10|}}}|{{colour|{{{10}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB11|{{#if:{{{11|}}}|{{colour|{{{11}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB12|{{#if:{{{12|}}}|{{colour|{{{12}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB13|{{#if:{{{13|}}}|{{colour|{{{13}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB14|{{#if:{{{14|}}}|{{colour|{{{14}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB15|{{#if:{{{15|}}}|{{colour|{{{15}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB16|{{#if:{{{16|}}}|{{colour|{{{16}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB17|{{#if:{{{17|}}}|{{colour|{{{17}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB18|{{#if:{{{18|}}}|{{colour|{{{18}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB19|{{#if:{{{19|}}}|{{colour|{{{19}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB20|{{#if:{{{20|}}}|{{colour|{{{20}}}}}|<nowiki>#</nowiki>000000}}}}<noinclude>{{ Set colours/doc}}
{{#vardefine:hueB1|{{#if:{{{1|}}}|{{colour|{{{1}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB2|{{#if:{{{2|}}}|{{colour|{{{2}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB3|{{#if:{{{3|}}}|{{colour|{{{3}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB4|{{#if:{{{4|}}}|{{colour|{{{4}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB5|{{#if:{{{5|}}}|{{colour|{{{5}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB6|{{#if:{{{6|}}}|{{colour|{{{6}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB7|{{#if:{{{7|}}}|{{colour|{{{7}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB8|{{#if:{{{8|}}}|{{colour|{{{8}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB9|{{#if:{{{9|}}}|{{colour|{{{9}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB10|{{#if:{{{10|}}}|{{colour|{{{10}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB11|{{#if:{{{11|}}}|{{colour|{{{11}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB12|{{#if:{{{12|}}}|{{colour|{{{12}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB13|{{#if:{{{13|}}}|{{colour|{{{13}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB14|{{#if:{{{14|}}}|{{colour|{{{14}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB15|{{#if:{{{15|}}}|{{colour|{{{15}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB16|{{#if:{{{16|}}}|{{colour|{{{16}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB17|{{#if:{{{17|}}}|{{colour|{{{17}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB18|{{#if:{{{18|}}}|{{colour|{{{18}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB19|{{#if:{{{19|}}}|{{colour|{{{19}}}}}|<nowiki>#</nowiki>000000}}}}{{#vardefine:hueB20|{{#if:{{{20|}}}|{{colour|{{{20}}}}}|<nowiki>#</nowiki>000000}}}}<noinclude>{{Set colours/doc}}
[[Category:Table templates|Set colours 2]]
[[Category:Table templates|Set colours 2]]
[[Category:Colour templates|Set colours 2]]
[[Category:Colour templates|Set colours 2]]

Latest revision as of 21:47, 11 July 2014

Template:Set colours allows you to define a set of up to 20 colours which can then be used consistently in an article. It is designed in particular for setting background colours in tables using {{Cellset}}, but it could be used in other contexts. It allows for changes of mind: having used {{Set colours}} to define the set of colours at the beginning of the document, if one is to be changed later, you only need change the code given to that template and the colour will change at every subsequent use.


Template:Cellset gives a background colour to a cell, and it is fed its values by {{Set colours}}. {{Cellset}} cannot be used unless {{Set colours}} has been included earlier in the article.

(This is essentially the same system as {{Colwidths}} – {{Cw}}, which defines column widths.)

These are not sophisticated templates nor complicated to use.

Use in table cells

1.  At the top of the page (or section) add {{Set colours}} with the Hex code for each colour you may wish to use (without the "#"). It will take up to 20 colours, so:

{{Set colours|FF0000|D0F0C0|00EF42|FE4EDA}}

- this defines four colours.

2.  In each cell which is to have this background colour, use {{cellset}}, followed by a pipe character ( | ): To use the first colour, put:

{{cellset|1}}|

To use the second colour, put:

{{cellset|2}}|

- and so forth.

A cell without {{cellset}} in it will simply be white as normal.

In the above example, it can produce:

Colour 1 Colour 2 Colour 3
Colour 3 Colour 4 Colour 2

If the colour has to be changed, simply change it in {{Set colours}} and every instance of {{cellset}} or {{cellset}} will follow that change.

Named colours

The system also uses {{Colour}}, which has a small list of colours which it recognises by name: see {{Colour/doc}}.

{{Set colours|red|violet|Welsh green}}

Use with {{Cw}}

The Set coloursCellset system is essentially the same idea as the pairing of {{Colwidths}} and {{Cw}}, and you might wish to use both in a table. However, do not use {{Cw}} in the same cell as {{Cellset}} as the former stops the latter from working: instead, have in a separate row with the {{Cw}} settings in them to fix the column widths.

Use outside a table

The {{Set colours}} template defines a series of Variables; {{#var:hue1}}, {{#var:hue2}} etc, so wherever a colour is required in a document, it can be retrieved using that variable.

Template:Set colours 2

{{Set colours 2}} is almost identical to {{Set colours}}, except that it defaults to black not to white. It is provided in case two sets of colours are wanted running in parallel, for example Set colours may define a cell background and Set colours 2 the font colour in the cell. Its variables are {{#var:hueB1}}, {{#var:hueB2}} etc.