added ColorMap, which are objects created from a color-map specification language (cmsl), which specifies linearly interpolated colormaps
added LazyColorMapCache, which stores, compiles and caches color maps on demand
implement existing built-in color maps with cmsl
implement CMAPS (dictionary of built-in color maps) with a LazyColorMapCache object
implement get_cmap, which is a convenience function used everywhere where color maps are required and returns a ColorMap object either by looking up its name in the built-in color maps, creates a new one if it is valid cmsl code, or returns the passed ColorMap if it already receives an instance
added 4 new built-in color maps based on #19
cmsl are comma-separated hexa-decimal values, with an arbitrary index before each value. If no index is specified, the indices of the colors are evenly spaced from 0 to 255, or between their neighbors with indices.
A color-map from blue to white to red may be specified equivalently as
00f,000,f00
00f,80:000,f00
0000ff,000,ff:f00
00:f00,80:000000,ff:ff0000.
If the first and last indices are not zero, they are assumed to not change until the respective boundaries, ie. a color map which only shows the sign as either blue or red may be specified as
79:00f,80:f00
If indices are supplied, they must be in ascending order from left to right.
Built-in color-maps are implemented as
sources = {
# black to white
'gray': '000,fff',
# white to red
'wred': 'fff,f00',
# white to blue
'wblue': 'fff,00f',
# black to red to yellow to white
'hot': '000,f00,ff0,fff',
# black to blue to cyan
'cold': '000,00f,0ff',
# combination of cold (reversed) and hot, centered around black
'coldnhot': '0ff,00f,80:000,f00,ff0,fff',
# combination of wblue (reversed) and wred, centered around white
'bwr': '00f,80:fff,f00',
# red to white to blue as in the french flag
'france': '0055a4,80:fff,ef4135',
# red to white to blue with brightness 0xd0
'seismic': 'd00000,80:d0d0d0,0000d0',
# cyan to white to magenta with brightness 0xd0
'coolio': '00d0d0,80:d0d0d0,d000d0',
# green to white to magenta with brightness 0xd0
'coleus': '00d000,80:d0d0d0,d000d0',
}
Here is an example of all built-in color-maps visualized:
In order:
- `gray`
- `wred`
- `wblue`
- `hot`
- `cold`
- `coldnhot`
- `bwr`
- `france`
- `seismic`
- `coolio`
- `coleus`
![image](https://user-images.githubusercontent.com/15217558/137356147-a8d7f6ee-a906-4763-99b3-03ffd58c3afd.png)
cmsl are comma-separated hexa-decimal values, with an arbitrary index before each value. If no index is specified, the indices of the colors are evenly spaced from 0 to 255, or between their neighbors with indices.
A color-map from blue to white to red may be specified equivalently as
00f,000,f00
00f,80:000,f00
0000ff,000,ff:f00
00:f00,80:000000,ff:ff0000
.If the first and last indices are not zero, they are assumed to not change until the respective boundaries, ie. a color map which only shows the sign as either blue or red may be specified as
79:00f,80:f00
If indices are supplied, they must be in ascending order from left to right.
Built-in color-maps are implemented as
Here is an example of all built-in color-maps visualized:
In order: - `gray` - `wred` - `wblue` - `hot` - `cold` - `coldnhot` - `bwr` - `france` - `seismic` - `coolio` - `coleus` ![image](https://user-images.githubusercontent.com/15217558/137356147-a8d7f6ee-a906-4763-99b3-03ffd58c3afd.png)