Difference between revisions of "Template:Hex3/doc"
Jump to navigation
Jump to search
imported>Verdy p m |
imported>Verdy p m |
||
| Line 12: | Line 12: | ||
; Examples | ; Examples | ||
| − | :* <tt><nowiki>{{ | + | :* <tt><nowiki>{{Hex3|0|0|0}}</nowiki></tt>gives {{Hex3|0|0|0}} |
| − | :* <tt><nowiki>{{subst: | + | :* <tt><nowiki>{{subst:Hex3|0|0|0|subst=subst:}}</nowiki></tt> gives <nowiki/>#<nowiki/>{{#switch:{{#expr:((0)/16-0.5 round 0)mod 16}}|-1|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F|?}}{{#switch:{{#expr:(0)mod 16}}|-1|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F|?}}<nowiki/>{{#switch:{{#expr:((0)/16-0.5 round 0)mod 16}}|-1|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F|?}}{{#switch:{{#expr:(0)mod 16}}|-1|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F|?}}<nowiki/>{{#switch:{{#expr:((0)/16-0.5 round 0)mod 16}}|-1|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F|?}}{{#switch:{{#expr:(0)mod 16}}|-1|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F|?}} |
| − | :* <tt><nowiki>{{ | + | :* <tt><nowiki>{{Hex3|123|45|67}}</nowiki></tt> gives {{Hex3|123|45|67}} |
| − | :* <tt><nowiki>{{subst: | + | :* <tt><nowiki>{{subst:Hex3|123|45|67|subst=subst:}}</nowiki></tt>gives <nowiki/>#<nowiki/>{{#switch:{{#expr:((123)/16-0.5 round 0)mod 16}}|-1|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F|?}}{{#switch:{{#expr:(123)mod 16}}|-1|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F|?}}<nowiki/>{{#switch:{{#expr:((45)/16-0.5 round 0)mod 16}}|-1|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F|?}}{{#switch:{{#expr:(45)mod 16}}|-1|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F|?}}<nowiki/>{{#switch:{{#expr:((67)/16-0.5 round 0)mod 16}}|-1|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F|?}}{{#switch:{{#expr:(67)mod 16}}|-1|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F|?}} |
| − | :* <tt><nowiki>{{ | + | :* <tt><nowiki>{{Hex3|255|255|255}}</nowiki></tt> gives {{Hex3|255|255|255}} |
| − | :* <tt><nowiki>{{subst: | + | :* <tt><nowiki>{{subst:Hex3|255|255|255|subst=subst:}}</nowiki></tt> gives <nowiki/>#<nowiki/>{{#switch:{{#expr:((255)/16-0.5 round 0)mod 16}}|-1|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F|?}}{{#switch:{{#expr:(255)mod 16}}|-1|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F|?}}<nowiki/>{{#switch:{{#expr:((255)/16-0.5 round 0)mod 16}}|-1|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F|?}}{{#switch:{{#expr:(255)mod 16}}|-1|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F|?}}<nowiki/>{{#switch:{{#expr:((255)/16-0.5 round 0)mod 16}}|-1|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F|?}}{{#switch:{{#expr:(255)mod 16}}|-1|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F|?}} |
; See also | ; See also | ||
| − | :* {{tl| | + | :* {{tl|RGB}} for formating as a "rgb(''r'',''g'',''b'')" value |
| − | :* {{tl| | + | :* {{tl|Hex2}} if you don't want three all at once. |
<includeonly> | <includeonly> | ||
Revision as of 12:55, 9 December 2008
- Description of use
- Converts three 8-bit numbers to hexadecimal.
- Useful for all sorts of color-related nefarious purposes.
- Input
-
- three parameters, each numeric in the range 0..255 (larger numbers will wrap around)
- #= (optional) allows you to change or remove the prefix for hex numbers (such as #) ; the default prefix is #.
- subst=subst: (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
-
- a triplet of two-digit hex numbers
- Examples
-
- {{Hex3|0|0|0}}gives #000000
- {{subst:Hex3|0|0|0|subst=subst:}} gives #000000
- {{Hex3|123|45|67}} gives #7B2D43
- {{subst:Hex3|123|45|67|subst=subst:}}gives #7B2D43
- {{Hex3|255|255|255}} gives #FFFFFF
- {{subst:Hex3|255|255|255|subst=subst:}} gives #FFFFFF
- See also