Difference between revisions of "Colors (API)"
(Fixing incorrect information telling people to use +/- instead of combine/subtract) |
|||
Line 41: | Line 41: | ||
==Colors== | ==Colors== | ||
− | Color constants include, in ascending bit order: | + | Color constants include, in ascending bit order (including character used in the paint program): |
{| class="wikitable" width="200px" | {| class="wikitable" width="200px" | ||
Line 48: | Line 48: | ||
! Hexadecimal | ! Hexadecimal | ||
! Binary | ! Binary | ||
+ | ! Paint Default | ||
|- | |- | ||
| colors.white | | colors.white | ||
Line 53: | Line 54: | ||
| align="right" | 0x1 | | align="right" | 0x1 | ||
| align="right" | 0000000000000001 | | align="right" | 0000000000000001 | ||
+ | | 0 | ||
|- | |- | ||
| colors.orange | | colors.orange | ||
Line 58: | Line 60: | ||
| align="right" | 0x2 | | align="right" | 0x2 | ||
| align="right" | 0000000000000010 | | align="right" | 0000000000000010 | ||
+ | | 1 | ||
|- | |- | ||
| colors.magenta | | colors.magenta | ||
Line 63: | Line 66: | ||
| align="right" | 0x4 | | align="right" | 0x4 | ||
| align="right" | 0000000000000100 | | align="right" | 0000000000000100 | ||
+ | | 2 | ||
|- | |- | ||
| colors.lightBlue | | colors.lightBlue | ||
Line 68: | Line 72: | ||
| align="right" | 0x8 | | align="right" | 0x8 | ||
| align="right" | 0000000000001000 | | align="right" | 0000000000001000 | ||
+ | | 3 | ||
|- | |- | ||
| colors.yellow | | colors.yellow | ||
Line 73: | Line 78: | ||
| align="right" | 0x10 | | align="right" | 0x10 | ||
| align="right" | 0000000000010000 | | align="right" | 0000000000010000 | ||
+ | | 4 | ||
|- | |- | ||
| colors.lime | | colors.lime | ||
Line 78: | Line 84: | ||
| align="right" | 0x20 | | align="right" | 0x20 | ||
| align="right" | 0000000000100000 | | align="right" | 0000000000100000 | ||
+ | | 5 | ||
|- | |- | ||
| colors.pink | | colors.pink | ||
Line 83: | Line 90: | ||
| align="right" | 0x40 | | align="right" | 0x40 | ||
| align="right" | 0000000001000000 | | align="right" | 0000000001000000 | ||
+ | | 6 | ||
|- | |- | ||
| colors.gray | | colors.gray | ||
Line 88: | Line 96: | ||
| align="right" | 0x80 | | align="right" | 0x80 | ||
| align="right" | 0000000010000000 | | align="right" | 0000000010000000 | ||
+ | | 7 | ||
|- | |- | ||
| colors.lightGray | | colors.lightGray | ||
Line 93: | Line 102: | ||
| align="right" | 0x100 | | align="right" | 0x100 | ||
| align="right" | 0000000100000000 | | align="right" | 0000000100000000 | ||
+ | | 8 | ||
|- | |- | ||
| colors.cyan | | colors.cyan | ||
Line 98: | Line 108: | ||
| align="right" | 0x200 | | align="right" | 0x200 | ||
| align="right" | 0000001000000000 | | align="right" | 0000001000000000 | ||
+ | | 9 | ||
|- | |- | ||
| colors.purple | | colors.purple | ||
Line 103: | Line 114: | ||
| align="right" | 0x400 | | align="right" | 0x400 | ||
| align="right" | 0000010000000000 | | align="right" | 0000010000000000 | ||
+ | | a | ||
|- | |- | ||
| colors.blue | | colors.blue | ||
Line 108: | Line 120: | ||
| align="right" | 0x800 | | align="right" | 0x800 | ||
| align="right" | 0000100000000000 | | align="right" | 0000100000000000 | ||
+ | | b | ||
|- | |- | ||
| colors.brown | | colors.brown | ||
Line 113: | Line 126: | ||
| align="right" | 0x1000 | | align="right" | 0x1000 | ||
| align="right" | 0001000000000000 | | align="right" | 0001000000000000 | ||
+ | | c | ||
|- | |- | ||
| colors.green | | colors.green | ||
Line 118: | Line 132: | ||
| align="right" | 0x2000 | | align="right" | 0x2000 | ||
| align="right" | 0010000000000000 | | align="right" | 0010000000000000 | ||
+ | | d | ||
|- | |- | ||
| colors.red | | colors.red | ||
Line 123: | Line 138: | ||
| align="right" | 0x4000 | | align="right" | 0x4000 | ||
| align="right" | 0100000000000000 | | align="right" | 0100000000000000 | ||
+ | | e | ||
|- | |- | ||
| colors.black | | colors.black | ||
Line 128: | Line 144: | ||
| align="right" | 0x8000 | | align="right" | 0x8000 | ||
| align="right" | 1000000000000000 | | align="right" | 1000000000000000 | ||
+ | | f | ||
|} | |} | ||
[[Category:APIs]] | [[Category:APIs]] |
Revision as of 11:37, 24 December 2013
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 non-American English (e.g. gray is spelt grey and lightGray is spelt lightGrey).
Colors (API) | ||
---|---|---|
Function | Return values | Description |
colors.combine(number color1, number color2, ...) | number value |
Combines a one or more colors (or sets of colors) into a larger set. |
colors.subtract(number colors, number color1, number color2, ...) | number value |
Removes one or more colors (or sets of colors) from an initial set. |
colors.test(number colors, number color) | boolean contained |
Tests whether color is contained within colors. |
print(colors.white + colors.white)will output 2 which is orange as opposed to
print(colors.combine(colors.white, colors.white))will output 1 which is white.
Furthermore, the Bit (API) may be used on sets of colors. For example,
bCableLeft = rs.getBundledInput("left") bCableRight = rs.getBundledInput("right") -- Get a number representing colors on in both right and left bundled cables commonColors = bit.band(bCableLeft, bCableRight) -- Get all the colors active on either right or left totalColors = bit.bor(bCableLeft, bCableRight) -- Get the colors which are active on right, or left, but not both at the same time exclusiveColors = bit.bxor(bCableLeft, bCableRight) -- Get the colors that are not active on the left offColorsA = bit.bnot(bCableLeft)
Colors
Color constants include, in ascending bit order (including character used in the paint program):
Color | Decimal | Hexadecimal | Binary | Paint Default |
---|---|---|---|---|
colors.white | 1 | 0x1 | 0000000000000001 | 0 |
colors.orange | 2 | 0x2 | 0000000000000010 | 1 |
colors.magenta | 4 | 0x4 | 0000000000000100 | 2 |
colors.lightBlue | 8 | 0x8 | 0000000000001000 | 3 |
colors.yellow | 16 | 0x10 | 0000000000010000 | 4 |
colors.lime | 32 | 0x20 | 0000000000100000 | 5 |
colors.pink | 64 | 0x40 | 0000000001000000 | 6 |
colors.gray | 128 | 0x80 | 0000000010000000 | 7 |
colors.lightGray | 256 | 0x100 | 0000000100000000 | 8 |
colors.cyan | 512 | 0x200 | 0000001000000000 | 9 |
colors.purple | 1024 | 0x400 | 0000010000000000 | a |
colors.blue | 2048 | 0x800 | 0000100000000000 | b |
colors.brown | 4096 | 0x1000 | 0001000000000000 | c |
colors.green | 8192 | 0x2000 | 0010000000000000 | d |
colors.red | 16384 | 0x4000 | 0100000000000000 | e |
colors.black | 32768 | 0x8000 | 1000000000000000 | f |