excolor.wallpaper

excolor.wallpaper.sigmoid_wallpaper(colors, background=None, size=(1280, 720), n=5, sigmoid_shift=None, sigmoid_span=None, midpoint=0.5, slope=25, shadow=True, fname=None)[source]

Creates a wallpaper with sigmoid patches.

This function generates a wallpaper with sigmoid patches, using the provided colors and background.

Parameters:
  • colors (list of str, str, matplotlib.colors.Colormap) – Input colors or colormap. Can be: - A list of color strings - A color name (str) - A colormap name (str) - A Colormap instance

  • background (str, or PIL.Image.Image, optional) – Background color or image. Can be: - A color name or hex string - A PIL Image object

  • size (tuple of int, default=(1280, 720)) – Size of the output image in pixels (width, height)

  • n (int, default=5) – Number of color patches. Used if list of colors is not provided explicitly.

  • sigmoid_shift (float, default=0.0) – Vertical shift of the sigmoid function (0 - 0.5)

  • sigmoid_span (float, default=1.0) – Vertical span of the sigmoid function (0.6 - 1)

  • midpoint (float, default=0.5) – Midpoint of the sigmoid function in fraction of the image width (0.2 - 0.8)

  • slope (float, default=25) – Slope of the sigmoid function

  • shadow (bool, default=True) – Whether to add a shadow to the wallpaper

  • fname (str, optional) – If provided, saves the image to the specified file path

Returns:

The generated wallpaper as a PIL Image object. If fname is provided, the image is also saved to the specified file path.

Return type:

PIL.Image.Image

Examples

>>> colors = ['#FF0000', '#00FF00', '#0000FF']
>>> wallpaper = sigmoid_wallpaper(colors, size=(800, 600))
>>> plt.imshow(wallpaper)
>>> plt.show()
excolor.wallpaper.perlin_wallpaper(colors, background=None, size=(1280, 720), n=5, shadow=True, center=(0, 0), seed=0, fname=None)[source]

Creates a wallpaper with Perlin noise patches.

This function generates a wallpaper with Perlin noise patches, using the provided colors and background.

Parameters:
  • colors (list of str, str, matplotlib.colors.Colormap) – Input colors or colormap. Can be: - A list of color strings - A color name (str) - A colormap name (str) - A Colormap instance

  • background (str, or PIL.Image.Image, optional) – Background color or image. Can be: - A color name or hex string - A PIL Image object

  • size (tuple of int, default=(1280, 720)) – Size of the output image in pixels (width, height)

  • n (int, default=5) – Number of color patches. Used if list of colors is not provided explicitly.

  • shadow (bool, default=True) – Whether to add a shadow to the wallpaper

  • center (tuple of float, default=(0, 0)) – Coordinates of the circle center from the right bottom corner in pixels

  • seed (int, default=0) – Random seed for the Perlin noise generation

  • fname (str, optional) – If provided, saves the image to the specified file path

Returns:

The generated wallpaper as a PIL Image object. If fname is provided, the image is also saved to the specified file path.

Return type:

PIL.Image.Image

Examples

>>> colors = ['#FF0000', '#00FF00', '#0000FF']
>>> wallpaper = perlin_wallpaper(colors, size=(800, 600))
>>> plt.imshow(wallpaper)
>>> plt.show()
excolor.wallpaper.perlin_lines(colors, background=None, size=(1280, 720), n=5, m=5, center=(0, 0), seed=0, fname=None)[source]

Creates a wallpaper with Perlin noise lines.

This function generates a wallpaper with Perlin noise lines, using the provided colors and background.

Parameters:
  • colors (list of str, str, matplotlib.colors.Colormap) – Input colors or colormap. Can be: - A list of color strings - A color name (str) - A colormap name (str) - A Colormap instance

  • background (str, or PIL.Image.Image, optional) – Background color or image. Can be: - A color name or hex string - A PIL Image object

  • size (tuple of int, default=(1280, 720)) – Size of the output image in pixels (width, height)

  • n (int, default=4) – Number of color line blocks.

  • m (int, default=5) – Number of lines in each block. Used if list of colors is not provided explicitly.

  • center (tuple of float, default=(0, 0)) – Coordinates of the circle center from the right bottom corner in pixels

  • seed (int, default=0) – Random seed for the Perlin noise generation

  • fname (str, optional) – If provided, saves the image to the specified file path

Returns:

The generated wallpaper as a PIL Image object. If fname is provided, the image is also saved to the specified file path.

Return type:

PIL.Image.Image

Examples

>>> colors = ['#FF0000', '#00FF00', '#0000FF']
>>> wallpaper = perlin_lines(colors, size=(800, 600))
>>> plt.imshow(wallpaper)
>>> plt.show()
excolor.wallpaper.gradient_wallpaper(colors=None, size=(1280, 720), angle=0, img=None, fname=None)[source]

Creates a wallpaper with a gradient background.

This function generates a wallpaper with a gradient fill, using either provided colors or colors sampled from sectors of a reference image.

Notes

When using a reference image: 1. The central rectangle (half width and height) is excluded 2. 16 sectors are defined around the center 3. Each sector’s average color is calculated from the non-excluded area 4. These colors are used as sources for the gradient

Parameters:
  • colors (list of str, str, matplotlib.colors.Colormap, or None, default=None) – Input colors or colormap. Can be: - A list of color strings - A color name (str) - A colormap name (str) - A Colormap instance

  • size (tuple of int, default=(1280, 720)) – Size of the output image in pixels (width, height)

  • angle (float, default=0) – Angle of the gradient in degrees. 0 means first color source is at the right edge. The angle increases in math style (counter-clockwise).

  • img (PIL.Image.Image or None, default=None) – Reference image. If provided, 16 colors will be sampled from image sectors.

  • fname (str, optional) – If provided, saves the image to the specified file path

Returns:

The generated wallpaper as a PIL Image object. If fname is provided, the image is also saved to the specified file path.

Return type:

PIL.Image.Image

Examples

>>> colors = ['#FF0000', '#00FF00', '#0000FF']
>>> wallpaper = gradient_wallpaper(colors, size=(800, 600))
>>> plt.imshow(wallpaper)
>>> plt.show()
excolor.wallpaper.triangle_wallpaper(colors=None, size=(1280, 720), img=None, density=10, padding=0.1, distortion=0.15, seed=0, fname=None)[source]

Creates a wallpaper with a grid of distorted triangles.

This function generates a wallpaper consisting of a grid of triangles that are randomly distorted and colored. The grid dimensions are calculated to maintain the aspect ratio of the requested image size.

Parameters:
  • colors (str or list of str or None, default=None) – List of colors for the triangles. If None, colors are sampled from the reference image.

  • size (tuple of int, default=(1280, 720)) – Size of the output image in pixels (width, height)

  • img (PIL.Image.Image or None, default=None) – Reference image. If provided, colors will be sampled from the image.

  • density (int, optional) – Number of grid cells in the shorter dimension.

  • padding (float, default=0.1) – Extra padding around the image to ensure coverage after distortion (0-1)

  • distortion (float, default=0.15) – Amount of random distortion to apply to grid points (0-1)

  • seed (int, default=0) – Random seed for the distortion and Perlin noise

  • fname (str, optional) – If provided, saves the image to the specified file path

Returns:

The generated wallpaper as a PIL Image object. If fname is provided, the image is also saved to the specified file path.

Return type:

PIL.Image.Image