Difference between revisions of "Oolite Colour Specifiers"

From Elite Wiki
(Page created. CORRECTIONS INVITED.)
 
m (Tagged as Oolite scripting)
 
(7 intermediate revisions by 2 users not shown)
Line 8: Line 8:
 
! Name !! RGBA value
 
! Name !! RGBA value
 
|-
 
|-
| blackColor || 0, 0, 0, 1
+
| blackColor || 0, 0, 0, 1
 
|-
 
|-
 
| darkGrayColor || 1/3, 1/3, 1/3, 1
 
| darkGrayColor || 1/3, 1/3, 1/3, 1
 +
|-
 +
| grayColor || 1/2, 1/2, 1/2, 1
 
|-
 
|-
 
| lightGrayColor || 2/3, 2/3, 2/3, 1
 
| lightGrayColor || 2/3, 2/3, 2/3, 1
 
|-
 
|-
 
| whiteColor || 1, 1, 1, 1
 
| whiteColor || 1, 1, 1, 1
|-
 
| grayColor || 1/2, 1/2, 1/2, 1
 
 
|-
 
|-
 
| redColor || 1, 0, 0, 1
 
| redColor || 1, 0, 0, 1
Line 41: Line 41:
  
 
==== RGBA tuples ====
 
==== RGBA tuples ====
Colours may also be specified in RGB or RGBA (red, green, blue, alpha [transparency]). RGB or RGBA tuples may be specified as arrays or as strings separated by spaces. The values may range from 0 to 1 or 0 to 255. (If no value is greater than 1, 0–1 is assumed, otherwise 0–255.) Examples:
+
Colours may also be specified in RGB or RGBA (red, green, blue, alpha [opacity]). RGB or RGBA tuples may be specified as arrays or as strings separated by spaces. The values may range from 0 to 1 or 0 to 255. (If no value is greater than 1, 0–1 is assumed, otherwise 0–255.) Examples:
* <code>"1 1 0"</code> yellow
+
* <code>"1 1 0"</code> yellow
* <code>"0 128 0 128"</code> medium green at 50% opacity
+
* <code>"0 128 0 128"</code> medium green at 50% opacity
 
* <code>(1, 0, 0)</code> – red
 
* <code>(1, 0, 0)</code> – red
 
  
 
==== RGBA dictionaries ====
 
==== RGBA dictionaries ====
Just in case you’re unsure of the order the RGB[A] components come in, you can use a dictionary:
+
Colours may also be specified as RGB[A] dictionaries. Accepted keys are '''red''', '''green''', '''blue''' and '''alpha''' (or '''opacity'''), all optional. Defaults are 0.0 for red, green and blue, 1.0 for alpha.
 
  {
 
  {
 +
    // Shade of cyan
 
     blue = 0.8;
 
     blue = 0.8;
 
     green = 0.8;
 
     green = 0.8;
 
  }
 
  }
Accepted keys are '''red''', '''green''', '''blue''' and '''alpha''' (or '''opacity'''), all optional (default: 0.0 for red, green and blue, 1.0 for alpha).
 
  
 
==== HSBA dictionaries ====
 
==== HSBA dictionaries ====
But wait, there’s more! Colours may also be specified as dictionaries in the [http://en.wikipedia.org/wiki/HSB_colour_space HSB colour space]. Accepted keys are '''hue''' (hue angle in degrees, required), '''saturation''', '''brightness''' (or '''value''') and '''alpha''' (or '''opacity'''). The default for the optional keys is 1.0.
+
Colours may also be specified as dictionaries in the [http://en.wikipedia.org/wiki/HSB_colour_space HSB colour space]. Accepted keys are '''hue''' (hue angle in degrees, required), '''saturation''', '''brightness''' (or '''value''') and '''alpha''' (or '''opacity'''). The default for the optional keys is 1.0.
 
  {
 
  {
 
     // Pale magenta
 
     // Pale magenta
Line 62: Line 61:
 
     saturation = 0.3;
 
     saturation = 0.3;
 
  }
 
  }
 +
 +
== Links ==
 +
Colours can be viewed at https://rgbcolorpicker.com/0-1 and many other websites
 +
 +
[[Category:Oolite scripting]]

Latest revision as of 15:19, 11 August 2025

Colour specifiers are used to declare colours in material attribute dictionaries, and in other contexts such as lasers in shipdata.plist. Colour specifiers take any of several forms:

Named colours

The simplest form of colour specifier is a string containing a colour name. The following names are supported:

Colour names
Name RGBA value
blackColor 0, 0, 0, 1
darkGrayColor 1/3, 1/3, 1/3, 1
grayColor 1/2, 1/2, 1/2, 1
lightGrayColor 2/3, 2/3, 2/3, 1
whiteColor 1, 1, 1, 1
redColor 1, 0, 0, 1
greenColor 0, 1, 0, 1
blueColor 0, 0, 1, 1
cyanColor 0, 1, 1, 1
yellowColor 1, 1, 0, 1
magentaColor 1, 0, 1, 1
orangeColor 1, 1/2, 0, 1
purpleColor 1/2, 0, 1/2, 1
brownColor 0.6, 0.4, 0.2, 1
clearColor 0, 0, 0, 0

RGBA tuples

Colours may also be specified in RGB or RGBA (red, green, blue, alpha [opacity]). RGB or RGBA tuples may be specified as arrays or as strings separated by spaces. The values may range from 0 to 1 or 0 to 255. (If no value is greater than 1, 0–1 is assumed, otherwise 0–255.) Examples:

  • "1 1 0" – yellow
  • "0 128 0 128" – medium green at 50% opacity
  • (1, 0, 0) – red

RGBA dictionaries

Colours may also be specified as RGB[A] dictionaries. Accepted keys are red, green, blue and alpha (or opacity), all optional. Defaults are 0.0 for red, green and blue, 1.0 for alpha.

{
   // Shade of cyan
   blue = 0.8;
   green = 0.8;
}

HSBA dictionaries

Colours may also be specified as dictionaries in the HSB colour space. Accepted keys are hue (hue angle in degrees, required), saturation, brightness (or value) and alpha (or opacity). The default for the optional keys is 1.0.

{
   // Pale magenta
   hue = 300;
   saturation = 0.3;
}

Links

Colours can be viewed at https://rgbcolorpicker.com/0-1 and many other websites