schrodinger.application.matsci.colorutils module

Contains utilities for color manipulation and conversion

Copyright Schrodinger, LLC. All rights reserved.

schrodinger.application.matsci.colorutils.get_distance(point_1, point_2)

Get the distance between points 1 and 2. Accepts points as arbitrary-length lists or tuples and calculates the distance between them.

Parameters:
  • point_1 (list or tuple) – The first point
  • point_2 (list or tuple) – The second point
Return type:

float

Returns:

The distance between the two points

schrodinger.application.matsci.colorutils.luminance_level(color_tuple)

Returns the luminance level of an RGB color tuple. Grabbed from the web, it is supposedly used to convert color TV to B&W. Luminance runs from 0 to X, where X is the upper limit of a color_tuple value (typically 255 or 65535). One place this algorithm is found is in the W3C accessibility working draft for color contrast in webpages.

Parameters:color_tuple (tuple) – The color’s RGB as a tuple
Return type:float
Returns:The luminance of the color
schrodinger.application.matsci.colorutils.color_distance(color1_rgb, color2_rgb)

Calculates the distance in u’v’ space between two colors

Parameters:
  • color1_rgb (tuple) – The RGB tuple of color 1
  • color2_rgb (tuple) – The RGB tuple of color 2
Return type:

float

Returns:

The distance between the two colors in u’v’ space

schrodinger.application.matsci.colorutils.ciexy_to_upvp(ciex, ciey)

Converts CIE(x,y) to CIE(u’v’), returns CIEu’ and CIEv’. Note that u’v’ are from the CIELUV color space (1976).

Parameters:
  • ciex (float) – CIE’s x component
  • ciey (float) – CIE’s y component
Return type:

float, float

Returns:

CIEu’ and CIEv’

schrodinger.application.matsci.colorutils.web_cie_to_rgb(color_tuple, whitepoint=(0.333, 0.333), xyz_to_rgb=True)

Converts CIEx,y,z data to RGB values if xyz_to_rgb is True. If false, the other way around.

Parameters:
  • color_tuple (tuple) – CIEx,y,z or RGB tuple for the color
  • whitepoint (tuple) – CIEx,y for white
  • xyz_to_rgb (bool) – Whether CIEx,y,z should be converted to RGB or the other way around
Return type:

tuple

Returns:

Converted CIEx,y,z or RGB tuple for the color