Web Editor : not defined width

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! :slight_smile:

1 Like
1 Like

Thx but it’s not the drop who makes problem, it’s after! :slight_smile:

Callback draw() doesn’t await for img to be fully loaded, much less for some1 to drop an image into the browser! :face_with_raised_eyebrow:

In my own sketch, I check whether img exists before using image(). And you should do the same. :wink:

1 Like

I will study that! :slight_smile:

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! :wink:

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! :wink:
If you can take a look:)

1 Like

You should properly indent your code so you & others can study them comfortably. :pensive:

Use this site service for it :arrow_right: Beautifier.io

Back to your code, even though you check img for the 1st image(), the 1 inside your triple loop is missing. :grimacing:

Actually, you should skip your whole triple for loop if there’s no img. :upside_down_face:

Also, you’re loading the p5js libraries 2 times in your “index.html” file! :astonished:

1 Like

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

https://editor.p5js.org/Pilou/sketches/PE_HwNoXH

I remake for more clear thing for me :slight_smile:
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!

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: :pensive:

Meaning you should check img before allowing that triple for () {} loop. :face_with_monocle:

Also, this is an “infinite” loop block :arrow_right: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! :infinity:

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

1 Like