With the next revision of Processing, it would really be great if we could eliminate this difficulty everyone is experiencing regarding these two things: detecting the mode (processing, online, present) and setting the size() accordingly.
Ideally, in order for one Processing sketch to run properly (without modification) in all 3 modes, we'd like to be able to do the following:
if (present) {
get screen.width, screen.height
optionally set size to match the screen,
or to a smaller size
} else if (online) {
indicate the default width+height we would like to "Export" in INDEX.HTML, but at runtime, we'd like to get the ACTUAL width+height in <OBJECT> (or in <PARAM>)
so the HTML could be modified without needing to re-export the sketch just to update the size
} else if (processing) {
we just call size(w,h) for a desired width+height
}
I understand from fry's postings on this topic, this is not a trivial request.
Perhaps this logic could be included in a more sophisticated "size()" function.
For example, fancySize(w1,h1, w2,h2, w3,h3)
could mean:
if (processing) use size(w1,h1)
if (online) use size(w2,h2)
if (present) use size(w3,h3)
... with the additional logic that specifying w=0,h=0
asks to GET the width+height from the environment,
so that "online" the values come from the OBJECT/PARAM
and for "present" the values come from the screen.width,screen.height
I am not saying my suggestion is the best way.
I just mean to emphasize that a lot of people would appreciate a solution to this issue.
Perhaps someone else has a more elegant solution.
Better still, ... perhaps an expert Java coder out there could provide working example code to update Processing that Casey and Ben could consider for inclusion in the next release.
... just a wish,
djones
fjen wrote on Aug 19th, 2007, 10:18am:ben,
i ran into this quite often, so it think it would be generally nice to have a variable that holds the type of mode the sketch is running in. like:
switch ( presentationMode )
{
case ONLINE: // i know "online" is there for that ..
case PROCESSING: // started from inside Processing
case STANDALONE: // application
}
F