Pilou
1
When I drop an image to the screen the width is not defined…in the function “draw” part !
https://editor.p5js.org/Pilou/sketches/qEPc9d1YD
I have not this problem when an image is preloaded!
https://editor.p5js.org/Pilou/sketches/SyG4qmVqQ
thx by advance for unblock that!
1 Like
Pilou
3
Thx but it’s not the drop who makes problem, it’s after!
Callback draw() doesn’t await for img to be fully loaded, much less for some1 to drop an image into the browser!
In my own sketch, I check whether img exists before using image(). And you should do the same.
1 Like
Pilou
6
https://editor.p5js.org/Pilou/sketches/5A7DeQN-H
Bravo ! With your blocks the program works perfectly
Just drop an image PNG (<=1024*512) with a transparent background for have an interesting result!
Here if you have not for test: image 1
image 2
I have only 2 messages on the console who are out of my knowledge!
If you can take a look:)
1 Like
You should properly indent your code so you & others can study them comfortably.
Use this site service for it Beautifier.io
Back to your code, even though you check img for the 1st image(), the 1 inside your triple loop is missing.
Actually, you should skip your whole triple for loop if there’s no img.
Also, you’re loading the p5js libraries 2 times in your “index.html” file!
1 Like
Pilou
8
Thx for the all advices…i will see that with natural light tomorrow!
If you don’t know, a free true gem of coding!
my little gallery
Pilou
9
https://editor.p5js.org/Pilou/sketches/PE_HwNoXH
I remake for more clear thing for me
And I have forgotten to increase the name of previous versions so they are devastated!
Here not yet drop…
you must obtain a variation of that in change t between (1-50) on the fly inside the code …or anything you want!
Next I will try to put your code…for drop an image against an yet existing one!
Pilou
10
https://editor.p5js.org/Pilou/sketches/0Q6enksIF
don’t know how skip the triple loop …try with “while” but…
Normally code is “beautifyed”…
My advice to you was this:
Meaning you should check img before allowing that triple for () {}
loop.
Also, this is an “infinite” loop block while (img) {
Given there’s nothing inside that block which can mutate variable img to “falsy”, it’s gonna repeat itself ad infinitum once it starts!
Pilou
12
Thx to Makio!
https://editor.p5js.org/Pilou/sketches/y1GHaBqyT
Right Click on the image for save it as you want
Just a curious thing - size saved image is 2048 *1024 : should be 1024 *512 ???
2 Likes