Difference between revisions of "Template:Color"

From RimWorld Wiki
Jump to navigation Jump to search
m (replace sandbox with doc)
 
(8 intermediate revisions by one other user not shown)
Line 24: Line 24:
  
 
--><span><!--
 
--><span><!--
Display color RGB if text=true or text parameter unused
+
Display color RGB if text=true
-->{{#ifeq:{{{text|true}}}|true |({{#var:red}}, {{#var:green}}, {{#var:blue}}{{#if:{{#var:alpha}}|, {{#var:alpha}}}}) }}<!--
+
-->{{#ifeq:{{{text|true}}}|false |({{#var:red}}, {{#var:green}}, {{#var:blue}}{{#if:{{#var:alpha}}|, {{#var:alpha}}}}) }}<!--
  
 
Draw the square
 
Draw the square
--> <div style="width:{{{size|16px}}};height:{{{size|16px}}};background-color:rgba({{#var:red}},{{#var:green}},{{#var:blue}},{{#if:{{#var:alpha}}|{{#var:alpha}}|255}});display:inline-block;border:1px solid black;vertical-align:middle;"></div><span></includeonly>
+
--> <abbr title="RGB: ({{#var:red}}, {{#var:green}}, {{#var:blue}})"><div style="width:{{{size|16px}}};height:{{{size|16px}}};background-color:rgba({{#var:red}},{{#var:green}},{{#var:blue}},{{#if:{{#var:alpha}}|{{#var:alpha}}|255}});display:inline-block;border:1px solid black;vertical-align:middle;"></div></abbr></span></includeonly><noinclude>{{Documentation}}</noinclude>

Latest revision as of 21:28, 25 August 2024

Documentation icon Template documentation[view] [edit] [history] [purge]

Overview[edit]

Color produces a small colored square using a provided set of RGB or optional RGBA values.


255, 255, 255: #FFFFFF; White

(255, 255, 255)

255, 0, 0: #FF0000; Red

(255, 0, 0)

0, 255, 0: #00FF00; Green

(0, 255, 0)

0, 0, 255: #0000FF; Blue

(0, 0, 255)

255, 255, 0: #FFFF00; Yellow

(255, 255, 0)

0, 255, 255: #00FFFF; Cyan

(0, 255, 255)

255, 0, 255: #FF00FF; Magenta

(255, 0, 255)

0, 0, 0: #000000; Black

(0, 0, 0)

Alpha[edit]

The alpha channel can be appended as a 4th value to control opacity. This can be represented as a percentage (0% - 100%), or value ranging from 0 - 1. If no alpha is provided, it defaults to 100%.

160,178,181,

{{Color|rgba=160,178,181,}}

160,178,181,0%

{{Color|rgba=160,178,181,0%}}

160, 178, 181, 25%

{{Color|rgba=160, 178, 181, 25%}}

(160,178,181,50%)

{{Color|rgba=(160,178,181,50%)}}

(160, 178, 181, 75%)

{{Color|rgba=(160, 178, 181, 75%)}}

( 160, 178, 181, 100% )

{{Color|rgba=( 160, 178, 181, 100% )}}

( 160, 178, 181, 0.5 )

{{Color|rgba=( 160, 178, 181, 0.5 )}}

( 160, 178, 181, 0.75 )

{{Color|rgba=( 160, 178, 181, 0.75 )}}

Optional parameters[edit]

Optional parameters include toggling the text color code, border, and resizing the square.

text=false

{{Color|rgb=160,178,181|text=false}}
(160, 178, 181)

border=false

{{Color|rgb=160,178,181|border=false}}

size=50px

{{Color|rgb=160,178,181|size=50px}}


Alternate usage[edit]

The format in which these values can be inputted is quite flexible:

  • Individual parameters:
{{Color|r|g|b}}
  • Comma separated list of values assigned to value rgb:
{{Color|rgb=r,g,b}}
  • Comma and space separated list:
{{Color|rgb=r, g, b}}
  • Comma and space separated list inside of parentheses:
{{Color|rgb=(r, g, b)}}

160|178|181

160|178|181|100

Examples[edit]

Here is some text. It is in English.

Things made of plasteel will use the color
. This color is blue.

Lorem ipsum dolor sit amet.

160,178,181

160, 178, 181

(160,178,181)

(160, 178, 181)

( 160, 178, 181 )

Rock

Bioferrite b.png

A cool rock I found.

Base Stats

Stuff Category
Rock
Stuff Color
Tech Level
Rock
Weapon Class
Rock

Invalid Inputs[edit]

Not within 0-255 rgb range:

{{Color|text=false|256,256,256}}
(256,256,256, 255, 255)
{{Color|rgb=700,700,700}}

Color name: red

{{Color|red}}

Hexidecimal color code: #ffeeaa

{{Color|rgb=#ffeeaa}}