Module:Utilities/doc: Difference between revisions

From Deadlock Wiki
Jump to navigation Jump to search
Sur (talk | contribs)
m get_slot_color with alpha colored divs
Sur (talk | contribs)
m more color examples for no_wrap
Line 14: Line 14:


===Examples===
===Examples===
To retrieve the hex color
To retrieve the color alone
<code><nowiki>{{#invoke:Utilities|get_slot_color|Tech}}</nowiki></code>
<code><nowiki>{{#invoke:Utilities|get_slot_color|Tech}}</nowiki></code>


Line 38: Line 38:
Tech colored div
Tech colored div
</div>
</div>
To get the color without otherwise necessary prefix/postfix wrapping:
<code><nowiki>{{#invoke:Utilities|get_slot_color|Tech|rgb|no_wrap=true}}</nowiki></code>
{{#invoke:Utilities|get_slot_color|Tech|rgb|no_wrap=true|debug_mode=true}}




To alter the alpha value using rgb dynamically:
To alter the alpha value using rgb dynamically:
<code><nowiki><div style="background-color: rgb({{#invoke:Utilities|get_slot_color|Armor|rgb|no_wrap=true}}, 0.5);">
<code><nowiki><div style="background-color: rgb({{#invoke:Utilities|get_slot_color|Armor|rgb|no_wrap=true}}, 1.0);">
Armor colored div with 0.5 alpha</div></nowiki></code>
Armor colored div with 1.0 alpha</div></nowiki></code>


<div style="background-color: rgb({{#invoke:Utilities|get_slot_color|Armor|rgb|no_wrap=true}}, 0.5);">
<div style="background-color: rgb({{#invoke:Utilities|get_slot_color|Armor|rgb|no_wrap=true}}, 1.0);">
Armor colored div with 0.5 alpha
Armor colored div with 1.0 alpha
</div>
</div>





Revision as of 22:35, 1 November 2024

Overview

Utility functions that serve any miscellaneous purpose

Functions

get_slot_color

Retrieve's the hex color of a certain slot/category, formerly known in english as Weapon, Vitality, and Spirit, though their unlocalized names are Weapon, Armor, and Tech.

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 - 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
  • debug_mode - (OPTIONAL) - used mostly for documentation purposes

Examples

To retrieve the color alone {{#invoke:Utilities|get_slot_color|Tech}}

#c288f0

To retrieve other color formats {{#invoke:Utilities|get_slot_color|Tech|rgb}}

rgb(194,136,240)


To style text: <span style="color: {{#invoke:Utilities|get_slot_color|Weapon}};">Weapon colored text</span>

Weapon colored text


To style divs: <div style="background-color: {{#invoke:Utilities|get_slot_color|Tech}};"> Tech colored div</div>

Tech colored div


To get the color without otherwise necessary prefix/postfix wrapping:

{{#invoke:Utilities|get_slot_color|Tech|rgb|no_wrap=true}}

194,136,240


To alter the alpha value using rgb dynamically: <div style="background-color: rgb({{#invoke:Utilities|get_slot_color|Armor|rgb|no_wrap=true}}, 1.0);"> Armor colored div with 1.0 alpha</div>

Armor colored div with 1.0 alpha


<div style="background-color: rgb({{#invoke:Utilities|get_slot_color|Armor|rgb|no_wrap=true}}, 0.2);"> Armor colored div with 0.2 alpha</div>

Armor colored div with 0.2 alpha