Image.crop

v0.1.7
Image.crop(x, y, w, h);

Crop an Image into an other Image.

Arguments

xThe x position of the image
yThe y position of the image
wThe width of the new cropped image
hThe height of the new cropped image

Returns

Imagethe cropped image

function setup()
    createWindow(400, 400);

    img = loadImage('examples/images/cat.jpg');

    cropped = img:crop(150, 150, 125, 200);
    -- -- or
    -- cropped = Image.crop(img, 150, 150, 125, 200);
end

function draw() 
    background('purple');

    image(img, 0, 0);
    image(cropped, x, y);
end

Output

See Image.crop in image.h