@@ -239,7 +239,7 @@ def _setSat(originalColours: np.ndarray, newSaturation: np.ndarray) -> np.ndarra
239239 ) / rangeColours [nonzeroMask ]
240240 maxColours [nonzeroMask ] = newSaturation [nonzeroMask ]
241241
242- # Zero out mid and max when rangeColours == 0
242+ # Zero out mid and max when rangeColours is 0
243243 midColours [~ nonzeroMask ] = 0
244244 maxColours [~ nonzeroMask ] = 0
245245
@@ -471,36 +471,30 @@ def blendLayers(
471471 opacity : float = 1.0 ,
472472 offsets : tuple [int , int ] = (0 , 0 ),
473473) -> Image .Image :
474- """Blend two layers (background, and foreground).
475-
476- Note if the background is smaller than the foreground then some of the foreground will be cut
477- off
478-
479- Args:
480- ----
481- background (Image.Image): The background layer.
482- foreground (Image.Image): The foreground layer (must be the same size as the background).
483- blendType (BlendType): The blend type to be applied.
484- opacity (float, optional): The opacity of the foreground image. Defaults to 1.0.
485- offsets (Tuple[int, int], optional): Offsets for the foreground layer. Defaults to (0, 0).
486-
487- Returns:
488- -------
489- Image.Image: The combined image.
490-
491- Examples:
474+ """Blend two layers (background and foreground), where the background may
475+ be cropped if smaller than the foreground.
476+
477+ :param Image.Image background: The background layer.
478+ :param Image.Image foreground: The foreground layer (must be the
479+ same size as the background).
480+ :param BlendType blendType: The blend type to be applied.
481+ :param float opacity: The opacity of the foreground image. Defaults to 1.0. (optional)
482+ :param tuple[int, int] offsets: Offsets for the foreground layer. Defaults to (0, 0). (optional)
483+ :return Image.Image: The combined image.
484+
485+ Examples
492486 --------
493- # Blend two layers with default parameters
494- combined_image = blendLayers(background_image, foreground_image, BlendType.NORMAL)
495-
496- # Blend two layers with custom opacity and offsets
497- combined_image = blendLayers(
498- background_image,
499- foreground_image,
500- BlendType.MULTIPLY,
501- opacity=0.7,
502- offsets=(100, 50)
503- )
487+ Blend two layers with default parameters
488+ >>> combined_image = blendLayers(background_image, foreground_image, BlendType.NORMAL)
489+
490+ Blend two layers with custom opacity and offsets
491+ >>> combined_image = blendLayers(
492+ ... background_image,
493+ ... foreground_image,
494+ ... BlendType.MULTIPLY,
495+ ... opacity=0.7,
496+ ... offsets=(100, 50)
497+ ... )
504498
505499 """
506500 arr = blendLayersArray (
@@ -521,38 +515,33 @@ def blendLayersArray(
521515 opacity : float = 1.0 ,
522516 offsets : tuple [int , int ] = (0 , 0 ),
523517) -> np .ndarray :
524- """Blend two layers (background, and foreground).
525-
526- Note if the background is smaller than the foreground then some of the foreground will be cut
527- off
528-
529- Args:
530- ----
531- background (np.ndarray | Image.Image): The background layer.
532- foreground (np.ndarray | Image.Image): The foreground layer (must be the same size as the background).
533- blendType (BlendType): The blend type to be applied.
534- opacity (float, optional): The opacity of the foreground image. Defaults to 1.0.
535- offsets (Tuple[int, int], optional): Offsets for the foreground layer. Defaults to (0, 0).
536-
537- Returns:
538- -------
539- np.ndarray: The combined image.
540-
541- Examples:
518+ """Blend two layers (background and foreground), where the background may
519+ be cropped if smaller than the foreground.
520+
521+ :param np.ndarray | Image.Image background: The background layer.
522+ :param np.ndarray | Image.Image foreground: The foreground layer (must be the
523+ same size as the background).
524+ :param BlendType blendType: The blend type to be applied.
525+ :param float opacity: The opacity of the foreground image. Defaults to 1.0. (optional)
526+ :param tuple[int, int] offsets: Offsets for the foreground layer. Defaults to (0, 0). (optional)
527+ :return np.ndarray: The combined image.
528+
529+ Examples
542530 --------
543- # Blend two layers with default parameters
544- combined_image = blendLayers(background_image, foreground_image, BlendType.NORMAL)
545-
546- # Blend two layers with custom opacity and offsets
547- combined_image = blendLayers(
548- background_image,
549- foreground_image,
550- BlendType.MULTIPLY,
551- opacity=0.7,
552- offsets=(100, 50)
553- )
531+ Blend two layers with default parameters
532+ >>> combined_image = blendLayers(background_image, foreground_image, BlendType.NORMAL)
533+
534+ Blend two layers with custom opacity and offsets
535+ >>> combined_image = blendLayers(
536+ ... background_image,
537+ ... foreground_image,
538+ ... BlendType.MULTIPLY,
539+ ... opacity=0.7,
540+ ... offsets=(100, 50)
541+ ... )
554542
555543 """
544+
556545 # Convert the Image.Image to a numpy array if required
557546 if isinstance (background , Image .Image ):
558547 background = np .array (background .convert ("RGBA" ))
0 commit comments