Wavelengths

From The Powder Toy
Jump to navigation Jump to search

Wavelengths are stored in the ctype field and determine the colour of the elements (e.g. PHOT, FILT, BRAY, BIZR, BIZS and BIZG.) They can be used as storage by setting the wavelengths to a certain amount and read that info by filtering out some wavelengths and letting others through. This save shows that use. Wavelengths are displayed at the HUD on top of the element name. In a full spectrum, the wavelengths on the left are red, and on the right they are blue. In between are the colours of the rainbow. When it isn't a full spectrum, then some colours will be missing. To set a wavelength, you need to set the ctype to get different wavelength. The wavelengths are:

Wavelength values (from blue to red)
Decimal value Hexadecimal value Color
1 1 0x1 Blue
2 2 0x2 Blue
3 4 0x4 Blue
4 8 0x8 Blue
5 16 0x10 Blue
6 32 0x20 Blue
7 64 0x40 Blue
8 128 0x80 Blue
9 256 0x100 Blue
10 512 0x200 Cyan
11 1024 0x400 Cyan
12 2048 0x800 Cyan
13 4096 0x1000 Green
14 8192 0x2000 Green
15 16384 0x4000 Green
16 32768 0x8000 Green
17 65536 0x10000 Green
18 131072 0x20000 Green
19 262144 0x40000 Yellow
20 524288 0x80000 Yellow
21 1048576 0x100000 Yellow
22 2097152 0x200000 Red
23 4194304 0x400000 Red
24 8388608 0x800000 Red
25 16777216 0x1000000 Red
26 33554432 0x2000000 Red
27 67108864 0x4000000 Red
28 134217728 0x8000000 Red
29 268435456 0x10000000 Red
30 536870912 0x20000000 Red

You can add them together, e.g. to get both wavelengths, 30 (the leftmost and the reddest wavelength) and 1 (the rightmost and the bluest wavelength) in the same spectra, you need to add the corresponding ctypes in the chart. 30.536870912 ctype for wave 30 = 536870912, 1.1 ctype for wave 1 = 1, 536870912 + 1 = 536870913. So, set the ctype of the PHOT or FILT or whatever to 536870913 to get both wavelengths 30 and 1.

If you know hexadecimal working with ctypes becomes very easy because every hexadecimal digit represents a cluster of 4 wavelengths. Assume we want to set the second, the fourth, the fifth and the eight wavelength: wavelength 2 = 0x2, wavelength 4 = 0x8, wavelength 5 = 0x10 and wavelength 8 = 0x80, adding them gives 0x2 + 0x8 + 0x10 + 0x80 = 0x9a.

 You can enter hexadecimal values in the console and in the PROP tool by using the 0x prefix.