diff --git a/patchwork.md b/patchwork.md index bf4280921..b0e8deb6b 100644 --- a/patchwork.md +++ b/patchwork.md @@ -132,3 +132,8 @@ Fix my docs Thanks @plt-hokusai. Kinda embarrassing this slipped through - I evidently need to lint examples too. ``` + +``` +34a2c835d412c0d9e1fb20a42b7f2cd2738289c7 +Add color table to docs (#553) +``` diff --git a/src/main/resources/data/computercraft/lua/rom/apis/colors.lua b/src/main/resources/data/computercraft/lua/rom/apis/colors.lua index a941fa287..211e9975c 100644 --- a/src/main/resources/data/computercraft/lua/rom/apis/colors.lua +++ b/src/main/resources/data/computercraft/lua/rom/apis/colors.lua @@ -1,15 +1,137 @@ ---- The Colors API allows you to manipulate sets of colors. --- --- This is useful in conjunction with Bundled Cables from the RedPower mod, --- RedNet Cables from the MineFactory Reloaded mod, and colors on Advanced --- Computers and Advanced Monitors. --- --- For the non-American English version just replace @{colors} with @{colours} --- and it will use the other API, colours which is exactly the same, except in --- British English (e.g. @{colors.gray} is spelt @{colours.grey}). --- --- @see colours --- @module colors +--[[- The Colors API allows you to manipulate sets of colors. + +This is useful in conjunction with Bundled Cables from the RedPower mod, RedNet +Cables from the MineFactory Reloaded mod, and colors on Advanced Computers and +Advanced Monitors. + +For the non-American English version just replace @{colors} with @{colours} and +it will use the other API, colours which is exactly the same, except in British +English (e.g. @{colors.gray} is spelt @{colours.grey}). + +On basic terminals (such as the Computer and Monitor), all the colors are +converted to grayscale. This means you can still use all 16 colors on the +screen, but they will appear as the nearest tint of gray. You can check if a +terminal supports color by using the function @{term.isColor}. + +Grayscale colors are calculated by taking the average of the three components, +i.e. `(red + green + blue) / 3`. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Default Colors
ColorValueDefault Palette Color
DecHexPaint/BlitPreviewHexRGBGrayscale
colors.white10x10#F0F0F0240, 240, 240
colors.orange20x21#F2B233242, 178, 51
colors.magenta40x42#E57FD8229, 127, 216
colors.lightBlue80x83#99B2F2153, 178, 242
colors.yellow160x104#DEDE6C222, 222, 108
colors.lime320x205#7FCC19127, 204, 25
colors.pink640x406#F2B2CC242, 178, 204
colors.gray1280x807#4C4C4C76, 76, 76
colors.lightGray2560x1008#999999153, 153, 153
colors.cyan5120x2009#4C99B276, 153, 178
colors.purple10240x400a#B266E5178, 102, 229
colors.blue20480x800b#3366CC51, 102, 204
colors.brown40960x1000c#7F664C127, 102, 76
colors.green81920x2000d#57A64E87, 166, 78
colors.red163840x4000e#CC4C4C204, 76, 76
colors.black327680x8000f#11111117, 17, 17
+ +@see colours +@module colors +]] local expect = dofile("rom/modules/main/cc/expect.lua").expect @@ -37,7 +159,7 @@ yellow = 0x10 -- terminal colour of #7FCC19. lime = 0x20 ---- Pink. Written as `6` in paint files and @{term.blit}, has a default +--- Pink: Written as `6` in paint files and @{term.blit}, has a default -- terminal colour of #F2B2CC. pink = 0x40 @@ -77,7 +199,8 @@ red = 0x4000 -- terminal colour of #191919. black = 0x8000 ---- Combines a set of colors (or sets of colors) into a larger set. +--- Combines a set of colors (or sets of colors) into a larger set. Useful for +-- Bundled Cables. -- -- @tparam number ... The colors to combine. -- @treturn number The union of the color sets given in `...` @@ -96,7 +219,8 @@ function combine(...) return r end ---- Removes one or more colors (or sets of colors) from an initial set. +--- Removes one or more colors (or sets of colors) from an initial set. Useful +-- for Bundled Cables. -- -- Each parameter beyond the first may be a single color or may be a set of -- colors (in the latter case, all colors in the set are removed from the @@ -121,7 +245,9 @@ function subtract(colors, ...) return r end ---- Tests whether `color` is contained within `colors`. +--- Tests whether `color` is contained within `colors`. Useful for Bundled +-- Cables. +-- -- -- @tparam number colors A color, or color set -- @tparam number color A color or set of colors that `colors` should contain.