summaryrefslogtreecommitdiff
path: root/silx/gui/colors.py
diff options
context:
space:
mode:
authorPicca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>2019-12-23 13:45:09 +0100
committerPicca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>2019-12-23 13:45:09 +0100
commit5d647cf9a6159afd2933da594b9c79ad93d3cd9b (patch)
tree2571025a602f68fc8933b01104dc712d41f84034 /silx/gui/colors.py
parent654a6ac93513c3cc1ef97cacd782ff674c6f4559 (diff)
New upstream version 0.12.0~b0+dfsg
Diffstat (limited to 'silx/gui/colors.py')
-rwxr-xr-x[-rw-r--r--]silx/gui/colors.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/silx/gui/colors.py b/silx/gui/colors.py
index aa2958a..365b569 100644..100755
--- a/silx/gui/colors.py
+++ b/silx/gui/colors.py
@@ -97,6 +97,7 @@ _AVAILABLE_LUTS = collections.OrderedDict([
('blue', _LUT_DESCRIPTION('builtin', 'yellow', True)),
('jet', _LUT_DESCRIPTION('matplotlib', 'pink', True)),
('viridis', _LUT_DESCRIPTION('resource', 'pink', True)),
+ ('cividis', _LUT_DESCRIPTION('resource', 'pink', True)),
('magma', _LUT_DESCRIPTION('resource', 'green', True)),
('inferno', _LUT_DESCRIPTION('resource', 'green', True)),
('plasma', _LUT_DESCRIPTION('resource', 'green', True)),
@@ -116,10 +117,11 @@ DEFAULT_MAX_LOG = 10
def rgba(color, colorDict=None):
- """Convert color code '#RRGGBB' and '#RRGGBBAA' to (R, G, B, A)
+ """Convert color code '#RRGGBB' and '#RRGGBBAA' to a tuple (R, G, B, A)
+ of floats.
- It also convert RGB(A) values from uint8 to float in [0, 1] and
- accept a QColor as color argument.
+ It also supports RGB(A) from uint8 in [0, 255], float in [0, 1], and
+ QColor as color argument.
:param str color: The color to convert
:param dict colorDict: A dictionary of color name conversion to color code
@@ -167,8 +169,8 @@ def greyed(color, colorDict=None):
"""Convert color code '#RRGGBB' and '#RRGGBBAA' to a grey color
(R, G, B, A).
- It also convert RGB(A) values from uint8 to float in [0, 1] and
- accept a QColor as color argument.
+ It also supports RGB(A) from uint8 in [0, 255], float in [0, 1], and
+ QColor as color argument.
:param str color: The color to convert
:param dict colorDict: A dictionary of color name conversion to color code
@@ -180,6 +182,19 @@ def greyed(color, colorDict=None):
return g, g, g, a
+def asQColor(color):
+ """Convert color code '#RRGGBB' and '#RRGGBBAA' to a `qt.QColor`.
+
+ It also supports RGB(A) from uint8 in [0, 255], float in [0, 1], and
+ QColor as color argument.
+
+ :param str color: The color to convert
+ :rtype: qt.QColor
+ """
+ color = rgba(color)
+ return qt.QColor.fromRgbF(*color)
+
+
def cursorColorForColormap(colormapName):
"""Get a color suitable for overlay over a colormap.
@@ -386,7 +401,7 @@ class Colormap(qt.QObject):
def setFromColormap(self, other):
"""Set this colormap using information from the `other` colormap.
- :param Colormap other: Colormap to use as reference.
+ :param ~silx.gui.colors.Colormap other: Colormap to use as reference.
"""
if not self.isEditable():
raise NotEditableError('Colormap is not editable')