Template:SlotColor/doc: Difference between revisions

From Deadlock Wiki
Jump to navigation Jump to search
Sur (talk | contribs)
m clarified that no_wrap is named parameter; clarified the no_wrap example's usage of alpha channel
Sur (talk | contribs)
m moved to Template:Color
Tag: Replaced
 
Line 1: Line 1:
Retrieve's the color of a certain slot/category in any color format (default hex), formerly known in english as Weapon, Vitality, and Spirit, though their unlocalized names are Weapon, Armor, and Tech. Utilizes [[Module:Utilities]]'s <code>get_slot_color</code> function.
{{delete|moved to Template:Color}}
 
===Parameters===
* '''slot''' - slot key, options are Weapon, Armor, and Tech
* '''color_format''' - color format - Defaults to hex. Valid options are hex, rgb, hsl, cmyk
* '''no_wrap''' - (OPTIONAL, Named parameter) - Defaults to false. Set to true to remove prefixes and postfixes of '#' from hex, or 'rgb()', 'hsl()', and 'cmyk()' from the other formats. May be useful for altering the values dynamically
 
===Examples===
To retrieve the color alone
<code><nowiki>{{SlotColor|Tech}}</nowiki></code>
 
{{SlotColor|Tech|debug_mode=true}}
 
To retrieve other color formats
<code><nowiki>{{SlotColor|Tech|rgb}}</nowiki></code>
 
{{SlotColor|Tech|rgb|debug_mode=true}}
 
 
To style text:
<code><nowiki><span style="color: {{SlotColor|Weapon}};">Weapon colored text</span></nowiki></code>
 
<span style="color: {{SlotColor|Weapon}};">Weapon colored text</span>
 
 
To style divs:
<code><nowiki><div style="background-color: {{SlotColor|Tech}};">
Tech colored div</div></nowiki></code>
 
<div style="background-color: {{SlotColor|Tech}};">
Tech colored div
</div>
 
 
To get the color without otherwise necessary prefix/postfix wrapping:
 
<code><nowiki>{{SlotColor|Tech|rgb|no_wrap=true}}</nowiki></code>
 
{{SlotColor|Tech|rgb|no_wrap=true|debug_mode=true}}
 
This can manually be wrapped like <code><nowiki>rgba({{SlotColor|Tech|no_wrap=true}}, 0.5)</nowiki></code> to customize the alpha channel (opacity/transparency) of the color to your liking. Note that with transparency, the color will vary on light or dark mode, so consider adding a white/black background behind to enforce consistency.
 
 
To alter the alpha value using rgb dynamically:
<code><nowiki><div style="background-color: rgba({{SlotColor|Armor|rgb|no_wrap=true}}, 1.0);">
Armor colored div with 1.0 alpha</div></nowiki></code>
 
<div style="background-color: rgba({{SlotColor|Armor|rgb|no_wrap=true}}, 1.0);">
Armor colored div with 1.0 alpha
</div>
 
 
 
<code><nowiki><div style="background-color: rgba({{SlotColor|Armor|rgb|no_wrap=true}}, 0.5);">
Armor colored div with 0.5 alpha</div></nowiki></code>
 
<div style="background-color: rgba({{SlotColor|Armor|rgb|no_wrap=true}}, 0.5);">
Armor colored div with 0.5 alpha
</div>
 
[[Category:Template documentation]]

Latest revision as of 21:43, 2 November 2024

“That was a whole lot of buildup for a whole lot of nothing.”
This template has been marked for deletion.
Reason: moved to Template:Color