Py5Image.copy()#

Copies a region of pixels from one image into another.

Examples#

example picture for copy()
1def setup():
2    global apples
3    apples = py5.load_image("apples.jpg")
4    x = py5.width//2
5    apples.copy(x, 0, x, py5.height, 0, 0, x, py5.height)
6
7
8def draw():
9    py5.image(apples, 0, 0)

Description#

Copies a region of pixels from one image into another. If the source and destination regions aren’t the same size, it will automatically resize source pixels to fit the specified target region. No alpha information is used in the process, however if the source image has an alpha channel set, it will be copied as well.

This function ignores image_mode().

Underlying Processing method: PImage.copy

Syntax#

copy() -> Py5Image
copy(src: Py5Image, sx: int, sy: int, sw: int, sh: int, dx: int, dy: int, dw: int, dh: int, /) -> None
copy(sx: int, sy: int, sw: int, sh: int, dx: int, dy: int, dw: int, dh: int, /) -> None

Parameters#

  • dh: int - destination image height

  • dw: int - destination image width

  • dx: int - x-coordinate of the destination’s upper left corner

  • dy: int - y-coordinate of the destination’s upper left corner

  • sh: int - source image height

  • src: Py5Image - a source image to copy pixels from

  • sw: int - source image width

  • sx: int - x-coordinate of the source’s upper left corner

  • sy: int - y-coordinate of the source’s upper left corner

Updated on January 16, 2022 16:51:21pm UTC