Image module

crop

procedureextensionsince 0.28.0Source

The width by height rectangle with its top left corner at x, y. Not ok when any part of it lies outside the image, or it's empty.

Example↗
image := make_image(10, 10, .RGBA8);
defer deinit(*image);

part, ok := crop(image, 2, 2, 4, 4);
defer deinit(*part);
assert(ok && part.width == 4);

_, ok = crop(image, 8, 8, 4, 4);
assert(!ok);
crop :: (
    image: Image,
    x: s32,
    y: s32,
    width: s32,
    height: s32
) -> (Image, ok: bool)

Parameters

image: Image
x: s32
y: s32
width: s32
height: s32

Returns

ok: bool

See also