Color generator based on a color image.
Generates colors based on an RGB image. A word will be colored using the mean color of the enclosing rectangle in the color image.
After construction, the object acts as a callable that can be passed as color_func to the word cloud constructor or to the recolor method.
- imagend-array, shape (height, width, 3)
Image to use to generate word colors. Alpha channels are ignored. This should be the same size as the canvas. for the wordcloud.
- default_colortuple or None, default=None
Fallback colour to use if the canvas is larger than the image, in the format (r, g, b). If None, raise ValueError instead.
__call__(self, word, font_size, font_path, …)
Generate a color for a given word using a fixed image.
__init__(self, image, default_color=None)¶
Initialize self. See help(type(self)) for accurate signature.