colormap

# Colormap (Cp) module

class vcs.colormap.Cp(Cp_name, Cp_name_src='default')[source]

The Colormap object allows the manipulation of the colormap index R,G,B values.

This class is used to define a colormap table entry used in VCS, or it can be used to change some or all of the colormap R,G,B attributes in an existing colormap table entry.

Some Useful Functions:
# Constructor
a=vcs.init()
# Show predefined colormap objects
a.show('colormap')
# Updates the VCS Canvas at user's request
a.update()
# If mode=1, automatic update
a.mode=1
#If mode=0, use update function to update the VCS Canvas.
a.mode=0
General use of a colormap:
# Create a VCS Canvas object
a=vcs.init()
#To Create a new instance of colormap use:
# Copies content of 'red' to 'new'
cp=a.createcolormap('new','quick')
# Copies content of 'default' to 'new'
cp=a.createcolormap('new')
Modifying an existing colormap:
cp=a.getcolormap('quick')
Overview of colormap attributes:
  • List all the colormap indices and R,G,B attribute values

    cp.list()
    
  • Setting colormap attribute values:

    # Index, R, G, B
    cp.color=16,100,0,0
    # Index range from 0 to 255, but can only modify from 0 to 239
    cp.color=16,0,100,0
    # R, G, B values range from 0 to 100, where 0 is low intensity and 100 is highest intensity
    cp.color=17,0,0,100
    
getcolorcell(index)[source]

Gets the R,G,B,A values of a colorcell.

Example
>>> a=vcs.init() # Create a vcs Canvas
>>> cmap = a.createcolormap('gcc_cmap') # Create a colormap
>>> cmap.getcolorcell(1) # Get RGBA values
[26, 0, 33, 100]
Parameters

index (int) – Index of a cell in the colormap. Must be an integer from 0-255.

Returns

A list containing the red, green, blue, and alpha values of the colorcell at the given index.

Return type

list

list()[source]

Lists the current values of object attributes

Example
>>> a=vcs.init()
>>> obj=a.getcolormap() # default
>>> obj.list() # print colormap attributes
---------- ... ----------
...
script(script_filename=None, mode=None)[source]

Saves out a copy of the colormap secondary method, in JSON or Python format to a designated file.

Note

If the the filename has a ‘.py’ at the end, it will produce a Python script. If no extension is given, then by default a .json file containing a JSON serialization of the object’s data will be produced.

Warning

VCS Scripts Deprecated. SCR script files are no longer generated by this function.

Example
>>> a=vcs.init()
>>> ex=a.getcolormap()
>>> ex.script('filename.py') # append to 'filename.py'
>>> ex.script('filename','w') # make/overwrite 'filename.json'
Parameters
  • script_filename (str) – Output name of the script file. If no extension is specified, a .json object is created.

  • mode (str) – Either ‘w’ for replace, or ‘a’ for append. Defaults to ‘a’, if not specified.

setcolorcell(index, red, green, blue, alpha=100.0)[source]

Sets the R,G,B,A values of a colorcell

Example
>>> a = vcs.init() # Create a vcs Canvas
>>> cmap = a.createcolormap('scc_cmap') # Create a colormap
>>> cmap.setcolorcell(40,80,95,1.0) # Set RGBA values
Parameters
  • index (int) – Integer from 0-255.

  • red (int) – Integer from 0-255 representing the concentration of red in the colorcell.

  • green (int) – Integer from 0-255 representing the concentration of green in the colorcell.

  • blue (int) – Integer from 0-255 representing the concentration of blue in the colorcell.

  • alpha (float) – Float representing the percentage of opacity in the colorcell.