Author: bugman Date: Sat Apr 15 08:45:11 2006 New Revision: 2467 URL: http://svn.gna.org/viewcvs/relax?rev=2467&view=rev Log: The Molmol and X11 colour lists can now be explicitly chosen by the 'molmol.write()' user function. Modified: 1.2/colour.py 1.2/prompt/molmol.py Modified: 1.2/colour.py URL: http://svn.gna.org/viewcvs/relax/1.2/colour.py?rev=2467&r1=2466&r2=2467&view=diff ============================================================================== --- 1.2/colour.py (original) +++ 1.2/colour.py Sat Apr 15 08:45:11 2006 @@ -28,7 +28,7 @@ """Class for all functions relating to colour.""" - def linear_gradient(self, value=None, start=None, colour_list='molmol', end=None): + def linear_gradient(self, value, start, end, colour_list=None): """Return an RGB colour array of the value placed on a linear colour gradient. The argment value should be a number between zero and one. The start and end colours can @@ -37,13 +37,37 @@ # Translate the end colour to RGB arrays if necessary. if type(start) == str: - if colour_list == 'molmol': + # Default (search the molmol list then the X11 list). + if colour_list == None: + try: + start = self.molmol_colours(start) + except: + start = self.x11_colours(start) + + # Molmol colours. + elif colour_list == 'molmol': start = self.molmol_colours(start) + + # X11 colours. + elif colour_list == 'x11': + start = self.x11_colours(start) # Translate the end colour to RGB arrays if necessary. if type(end) == str: - if colour_list == 'molmol': + # Default (search the molmol list then the X11 list). + if colour_list == None: + try: + end = self.molmol_colours(end) + except: + end = self.x11_colours(end) + + # Molmol colours. + elif colour_list == 'molmol': end = self.molmol_colours(end) + + # X11 colours. + elif colour_list == 'x11': + end = self.x11_colours(end) # Truncate the value to be between zero and one. if value < 0.0: Modified: 1.2/prompt/molmol.py URL: http://svn.gna.org/viewcvs/relax/1.2/prompt/molmol.py?rev=2467&r1=2466&r2=2467&view=diff ============================================================================== --- 1.2/prompt/molmol.py (original) +++ 1.2/prompt/molmol.py Sat Apr 15 08:45:11 2006 @@ -109,7 +109,7 @@ self.__relax__.generic.molmol.view(run=run) - def write(self, run=None, data_type=None, style="classic", colour_start=None, colour_end=None, file=None, dir='molmol', force=0): + def write(self, run=None, data_type=None, style="classic", colour_start=None, colour_end=None, colour_list=None, file=None, dir='molmol', force=0): """Function for creating Molmol macros. Keyword Arguments @@ -121,9 +121,12 @@ style: The style of the macro. - colour_start: The starting colour of the linear colour gradient. - - colour_end: The ending colour of the linear colour gradient. + colour_start: The starting colour, either an array or string, of the linear colour + gradient. + + colour_end: The ending colour, either an array or string, of the linear colour gradient. + + colour_list: The list of colours to match the start and end strings. file: The name of the file. @@ -146,10 +149,17 @@ The values are coloured based on a linear colour gradient which is specified through the 'colour_start' and 'colour_end' arguments. These arguments can either be a string to - identify one of the RGB (red, green, blue) colour arrays listed in the table below, or you + identify one of the RGB (red, green, blue) colour arrays listed in the tables below, or you can give the RGB vector itself. For example, colour_start='white' and colour_start=[1.0, 1.0, 1.0] both select the same colour. Leaving both arguments at None will select the default colour gradient which for each type of analysis is described below. + + When supplying the colours as strings, two lists of colours can be selected from which to + match the strings. These are the default Molmol colour list and the X11 colour list, both + of which are described in the tables below. The default behaviour is to first search the + Molmol list and then the X11 colour list, raising an error if neither contain the string. + To explicitly select these lists, set the 'colour_list' argument to either 'molmol' or + 'x11'. Examples @@ -229,3 +239,6 @@ # Molmol RGB colour list. write.__doc__ = write.__doc__ + "\n\n" + Colour.molmol_colours.__doc__ + "\n\n" + + # X11 RGB colour list. + write.__doc__ = write.__doc__ + "\n\n" + Colour.x11_colours.__doc__ + "\n\n"