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])
Parameters
src
String: relative path or URL for the image.
alt
String: alternate text for the image.
crossOrigin
String: crossOrigin property to use when fetching the image.
successCallback
Function: function to call once the image loads. The new image will be passed to the function as a p5.Element object.
Returns
p5.Element: new p5.Element object.
Notice any errors or typos? Please let us know. Please feel free to edit src/dom/dom.js and open a pull request!