module documentation

颜色处理函数。

AdvancedGradientPalette 由两种以上基础颜色组成的高级渐变。
ClusterColoringPalette 适用于在绘制聚类时为顶点着色的调色板。
GradientPalette 渐变调色板的基类
Palette 颜色调色板的基类。
PrecalculatedPalette 一个从预计算颜色列表中返回颜色的调色板
RainbowPalette 一种沿着尺度变化颜色色调的调色板。
函数 clamp 将给定值限制在最小值和最大值之间
函数 color_name_to_rgb 将支持的颜色格式中的颜色转换为R-G-B值。
函数 color_name_to_rgba 将支持的某种颜色格式的颜色转换为R-G-B-A值。
函数 color_to_html_format 将给定的3元组或4元组颜色格式化为HTML格式。
函数 darken 创建一个由RGB三元组给出的颜色的较暗版本。
函数 hsl_to_rgb 将给定HSL坐标(色相、饱和度、亮度)的颜色转换为RGB坐标。
函数 hsla_to_rgba 将给定HSLA坐标(色相、饱和度、亮度、透明度)的颜色转换为RGBA坐标。
函数 hsv_to_rgb 将给定HSV坐标(色调、饱和度、亮度)的颜色转换为RGB坐标。
函数 hsva_to_rgba 将由其HSVA坐标(色调、饱和度、明度、透明度)给出的颜色转换为RGB坐标。
函数 lighten 创建一个由RGB三元组给出的颜色的较亮版本。
函数 rgb_to_hsl 将由其RGB坐标给出的颜色转换为HSL坐标(色调、饱和度、亮度)。
函数 rgb_to_hsv 将给定RGB坐标的颜色转换为HSV坐标(色调、饱和度、亮度)。
函数 rgba_to_hsla 将给定RGBA坐标的颜色转换为HSLA坐标(色调、饱和度、亮度、透明度)。
函数 rgba_to_hsva 将给定RGBA坐标的颜色转换为HSVA坐标(色调、饱和度、值、透明度)。
变量 default_edge_colors 未记录
变量 known_colors 未记录
变量 palettes 未记录
def clamp(value, min_value, max_value): (source)

将给定值限制在最小值和最大值之间

def color_name_to_rgb(color, palette=None): (source)

将给定的一种支持的颜色格式的颜色转换为R-G-B值。

这是通过调用color_name_to_rgba然后丢弃alpha值来完成的。

另请参阅
有关此函数理解的格式的更多详细信息,请参阅color_name_to_rgba。
def color_name_to_rgba(color, palette=None): (source)

将给定的一种支持的颜色格式转换为R-G-B-A值。

示例:

>>> color_name_to_rgba("red")
(1.0, 0.0, 0.0, 1.0)
>>> color_name_to_rgba("#ff8000") == (1.0, 128/255.0, 0.0, 1.0)
True
>>> color_name_to_rgba("#ff800080") == (1.0, 128/255.0, 0.0, 128/255.0)
True
>>> color_name_to_rgba("#08f") == (0.0, 136/255.0, 1.0, 1.0)
True
>>> color_name_to_rgba("rgb(100%, 50%, 0%)")
(1.0, 0.5, 0.0, 1.0)
>>> color_name_to_rgba("rgba(100%, 50%, 0%, 25%)")
(1.0, 0.5, 0.0, 0.25)
>>> color_name_to_rgba("hsla(120, 100%, 50%, 0.5)")
(0.0, 1.0, 0.0, 0.5)
>>> color_name_to_rgba("hsl(60, 100%, 50%)")
(1.0, 1.0, 0.0, 1.0)
>>> color_name_to_rgba("hsv(60, 100%, 100%)")
(1.0, 1.0, 0.0, 1.0)
参数
color

the color to be converted in one of the following formats:

  • CSS3 color specification: #rrggbb, #rgb, #rrggbbaa, #rgba, rgb(red, green, blue), rgba(red, green, blue, alpha), hsl(hue, saturation, lightness), hsla(hue, saturation, lightness, alpha), hsv(hue, saturation, value) and hsva(hue, saturation, value, alpha) where the components are given as hexadecimal numbers in the first four cases and as decimals or percentages (0%-100%) in the remaining cases. Red, green and blue components are between 0 and 255; hue is between 0 and 360; saturation, lightness and value is between 0 and 100; alpha is between 0 and 1.
  • Valid HTML color names, i.e. those that are present in the HTML 4.0 specification
  • Valid X11 color names, see http://en.wikipedia.org/wiki/X11_color_names
  • Red-green-blue components given separately in either a comma-, slash- or whitespace-separated string or a list or a tuple, in the range of 0-255. An alpha value of 255 (maximal opacity) will be assumed.
  • Red-green-blue-alpha components given separately in either a comma-, slash- or whitespace-separated string or a list or a tuple, in the range of 0-255
  • A single palette index given either as a string or a number. Uses the palette given in the palette parameter of the method call.
palette如果向方法传递单个数字时要使用的调色板。必须是colors.Palette的实例。
返回
与给定颜色对应的RGBA值以4元组形式表示。由于这些颜色主要由Cairo例程使用,元组中包含0.0到1.0范围内的浮点数
def color_to_html_format(color): (source)

将作为3元组或4元组给出的颜色格式化为HTML格式。

HTML格式简单地由#rrggbbaa给出,其中rr以十六进制格式表示红色分量,gg表示绿色分量,bb表示蓝色分量,gg表示透明度级别。透明度级别是可选的。

def darken(color, ratio=0.5): (source)

创建一个由RGB三元组给出的颜色的较暗版本。

这是通过使用给定的比例将原始颜色与黑色混合来完成的。比例为1.0将产生完全黑色的颜色,比例为0.0将产生原始颜色。alpha值保持不变。

def hsl_to_rgb(h, s, l): (source)

将给定颜色的HSL坐标(色调、饱和度、亮度)转换为RGB坐标。

每个HSL坐标必须在[0, 1]范围内。

def hsla_to_rgba(h, s, l, alpha=1.0): (source)

将由其HSLA坐标(色调、饱和度、亮度、透明度)给定的颜色转换为RGBA坐标。

每个HSLA坐标必须在[0, 1]范围内。

def hsv_to_rgb(h, s, v): (source)

将给定的HSV坐标(色调、饱和度、明度)颜色转换为RGB坐标。

每个HSV坐标必须在[0, 1]范围内。

def hsva_to_rgba(h, s, v, alpha=1.0): (source)

将由其HSVA坐标(色调、饱和度、明度、透明度)给出的颜色转换为RGB坐标。

每个HSVA坐标必须在[0, 1]范围内。

def lighten(color, ratio=0.5): (source)

创建一个由RGB三元组给出的颜色的较浅版本。

这是通过使用给定的比例将原始颜色与白色混合来完成的。比例为1.0将产生完全白色的颜色,比例为0.0将产生原始颜色。

def rgb_to_hsl(r, g, b): (source)

将给定的RGB坐标颜色转换为HSL坐标(色调、饱和度、亮度)。

每个RGB坐标必须在[0, 1]范围内。

def rgb_to_hsv(r, g, b): (source)

将给定的RGB坐标颜色转换为HSV坐标(色调、饱和度、明度)。

每个RGB坐标必须在[0, 1]范围内。

def rgba_to_hsla(r, g, b, alpha=1.0): (source)

将给定的RGBA坐标颜色转换为HSLA坐标(色调、饱和度、亮度、透明度)。

每个RGBA坐标必须在[0, 1]范围内。

def rgba_to_hsva(r, g, b, alpha=1.0): (source)

将给定的RGBA坐标颜色转换为HSVA坐标(色调、饱和度、明度、透明度)。

每个RGBA坐标必须在[0, 1]范围内。

default_edge_colors: dict = (source)

未记录

known_colors: dict = (source)

未记录

palettes = (source)

未记录