We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have just updated my processing to Processing 3.x, but loads of my sketches have stopped working. e.g:
CODE:
void setup() {
background(33);
source = loadImage("5.jpg");
size(source.width, source.height);
}
ERROR: "The size of this sketch could not be determined from your code....."
any idea how I can set the size of the sketch to the PImage size?
Answers
If size() doesn't accept variables or other expressions as its argument, it's merely an illusion which can be replaced by some user configuration inside the PDE! :(|)
That is, it's not programmatically anymore! :-\"
Every Processing big series comes w/ loss of features & flexibility! X(
thats a bit annoying :-( , i have hundreds of sketches that resize dependent on variables? GRRRR
I found this example useful, even though it requires some tinkering to work on version 3.0. Thanks @_vk.
http://forum.processing.org/two/discussion/comment/48246/#Comment_48246
Cool! :-c
Perhaps you could post the tinkered version compatible with 3.0, for reference.
There are just a couple of minor tweaks. For one, MIN_WINDOW_WIDTH and MIN_WINDOW_WIDTH no longer exist as system constants, so I had to define them:
And the system prompted me to change a couple of instances of
frame.whatever()
tosurface.whatever()
. That's all it took, but there's still an issue with an extra height inset sized band of pixels at the bottom of the image. I haven't figured that one out yet. Here's the whole thing:surely an easier way? ;-)
Sorry - but I think the removal of variables from the SIZE() function is just plain dumb! WTF???
Is Processing supposed to be artist, amateur programmer friendly? =))
Just use surface.setSize() and be done with it. I've added more background here: https://github.com/processing/processing/wiki/Changes-in-3.0#things-that-may-break-your-2x-sketches
@GoToLoop The negativity is unnecessary. If you're not here to help people find solutions, then keep quiet. The extra noise gets in the way of what are much simpler solutions.
https://processing.org/reference/settings_.html
Using @fry 's advice and example I was able to cut the above code down to this, much easier to deal with:
I'm curious whether
setResizable(true);
is actually necessary for setSize()?It works without the setResizable(), at least in the couple of examples I have here.
Seems like surface is the new frame.
I wonder whether it got setTitle() & setVisible() too?
setTitle() yes, I dunno about setVisible().
the new version is too painful...none of my old sketches work at all (or run painfully slow).
gone back to 2.x. :-(
It's clear that presenting the beta as the main download is a big mistake! :-t
And that ends up falling at us, the answerers... [-(
Here is the easiest solution in only two simple steps. Anyway, Mr. Fry had already answered that question.
In your setup(), do as this :
- Import the image.
- Use the method setSize() to the surface object, with the dimensions of the imported image as parameters.
Here is my solution to this problem, just comment the line size and putting the information as below: