Creates an <img>
element that can appear outside of the canvas.
The first parameter, src
, is a string with the path to the image file. src
should be a relative path, as in '/assets/image.png'
, or a URL, as in 'https://example.com/image.png'
.
The second parameter, alt
, is a string with the alternate text for the image. An empty string ''
can be used for images that aren't displayed.
The third parameter, crossOrigin
, is optional. It's a string that sets the crossOrigin property of the image. Use 'anonymous'
or 'use-credentials'
to fetch the image with cross-origin access.
The fourth parameter, callback
, is also optional. It sets a function to call after the image loads. The new image is passed to the callback function as a p5.Element object.
Examples
Syntax
createImg(src, alt)
createImg(src, alt, [crossOrigin], [successCallback])