loadImage(path);
Load a png or jpeg image
Arguments
path
The local image pathReturns
Image
The image instancefunction setup()
createWindow(600, 600);
img = loadImage('/path/to/mypic.png');
end
function draw()
background('purple');
image(img, 0, 0);
end
image(img, x, y, [w], [h]);
Draw an image to the screen
Arguments
img
The Image instancex
The x position of the imagey
The y position of the image[w]
The width of the image, if not specified, using source width[h]
The height of the image, if not specified, using source heightImage.crop(x, y, w, h);
Crop an Image into an other Image.
Arguments
x
The x position of the imagey
The y position of the imagew
The width of the new cropped imageh
The height of the new cropped imageReturns
Image
the cropped imagefunction 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