-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loading images with require #14
Comments
Did you ever figure this out? |
HI there, I am struggling with the same issue of passing an image to the p5-wrapper. |
I think I have found the solution but still working on it tho! Its something along the following lines; FIRST import turnBuddy from '../img/pmini3.png'
import pickBuddy from '../img/pmini2.png'
import robotBuddy from '../img/pmini1.png' You do not necessarily have to use them in your code, its just for reference purposes for react to correctly build the project with your "images at the correct location". After build process your images will be located @ [... yourReactDirectory]/build/static/media with some hash like numbers added to their original names. My pmini2.png file became pmini2.263db811.png after the build. As far as I could observe this renaming process happens once so you wont have to update your references each time a build is executed. SECOND using loadImage() method of p5 I could some how access and touch the images. Loads without an error BUT when I console.log the image; the image array appears to be empty. All the rest attributes including the image size and name data appears to be correct. But the image wont show up! let address = 'http://127.0.0.1:3000/image/'
let turnBuddy = p5.loadImage(address + '3', () => {
console.log(turnBuddy)
p5.image(turnBuddy, 0, 0, 50, 50)
}) So far my solution ... |
I have updated the examples in my fork of this repo to show a workaround for loading images, feel free to check the example there and hopefully it helps in the future. I will be aiming to look into the types library more because it is missing modules like |
Closing due to inactivity. |
I could be doing something wrong here, but how could I pass images to p5 here?
Component
sketch.js
The text was updated successfully, but these errors were encountered: