Difference between revisions of "Template:Hex2/doc"

From blackwiki
Jump to navigation Jump to search
imported>Borgx
m (+id)
imported>Amalthea
(Use safesubst: (meta:Help:Safesubst))
Line 2: Line 2:
 
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
 
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
 
; Description of use
 
; Description of use
: Converts a 8-bit number to hexadecimal using two digits.
+
: Converts a 8-bit number to hexadecimal using two digits, useful for formating RGB color components.
: Useful for formating RGB color components.
+
: This template can be substituted.
  
 
; Input
 
; Input
:* a parameter, numeric in the range 0..255 (larger numbers will wrap around)
+
:* one parameter, numeric in the range 0..255 (larger numbers will wrap around)
:* <tt>subst=subst:</tt> ''(optional)'' allows to perform a permanent substitution of the internal sub-expressions (or subtemplates that may be used), and keep only the result of the evaluations when saving a page using this template. You should pass this parameter in addition to calling the template using the "subst:" prefix that just performs a permanent template expansion and permanent substitution of parameters. (See examples below).
 
  
 
; Output
 
; Output
Line 14: Line 13:
 
; Examples
 
; Examples
 
:* <tt><nowiki>{{Hex2|0}}</nowiki></tt>gives {{Hex2|0}}
 
:* <tt><nowiki>{{Hex2|0}}</nowiki></tt>gives {{Hex2|0}}
:* <tt><nowiki>{{subst:Hex2|0|subst=subst:}}</nowiki></tt> gives 00
+
:* <tt><nowiki>{{subst:Hex2|0}}</nowiki></tt> gives 00
 
:* <tt><nowiki>{{Hex2|123}}</nowiki></tt> gives {{Hex2|123}}
 
:* <tt><nowiki>{{Hex2|123}}</nowiki></tt> gives {{Hex2|123}}
:* <tt><nowiki>{{subst:Hex2|123|subst=subst:}}</nowiki></tt>gives 7B
+
:* <tt><nowiki>{{subst:Hex2|123}}</nowiki></tt>gives 7B
 
:* <tt><nowiki>{{Hex2|255}}</nowiki></tt> gives {{Hex2|255}}
 
:* <tt><nowiki>{{Hex2|255}}</nowiki></tt> gives {{Hex2|255}}
:* <tt><nowiki>{{subst:Hex2|255|subst=subst:}}</nowiki></tt> gives FF
+
:* <tt><nowiki>{{subst:Hex2|255}}</nowiki></tt> gives FF
  
 
; See also
 
; See also

Revision as of 10:20, 23 April 2010

Description of use
Converts a 8-bit number to hexadecimal using two digits, useful for formating RGB color components.
This template can be substituted.
Input
  • one parameter, numeric in the range 0..255 (larger numbers will wrap around)
Output
  • a two-digit hex number
Examples
  • {{Hex2|0}}gives 00
  • {{subst:Hex2|0}} gives 00
  • {{Hex2|123}} gives 7B
  • {{subst:Hex2|123}}gives 7B
  • {{Hex2|255}} gives FF
  • {{subst:Hex2|255}} gives FF
See also
  • {{Hex3}} for formating 3 RGB components at once.