I have posted a question regarding moving image in p5js which is answered in this question. I have another problem with p5js when I try to upload an image in React input field.
I take input as
<input
type="file"
name="file"
id="file"
onChange={(e) => setSelectedFile(e.target.files[0])}
/>
And use it in draw function like following:
if (selectedFile != null) {
const url = URL.createObjectURL(selectedFile);
backgroundImage = p5.loadImage(url);
}
The strange behavior is that it does not change the image and gives blank screen canvas. I want to upload image as input element, not createFileInput().
I have uploaded the complete code into StackBlitz.
I don't want to copy the code here because it is already mentioned in previous question and StackBlitz.
Any help is appreciated.