some basic switch-case-question
in
Programming Questions
•
8 months ago
Assume I want to create a window that fits the users screen and I like to use switch-case-contruct for this like in the script shown below
Else I would be forced to use If -contructs instead, sure, but just for interest: Is it possible?
- void setup(){
- int iw;
- int ih;
- switch (displayWidth) {
- case > 1024:
- iw = 1024;
- case > 800:
- iw = 800;
- case > 640:
- iw = 640;
- default:
- iw = 320;
- }
- switch (displayHeight) {
- case > 768:
- ih = 768;
- case > 600:
- ih = 600;
- case > 480:
- ih = 480;
- default:
- ih = 240;
- }
- size(iw, ih, P3D);
- }
- void draw() {
- // don't get here yet :(
- }
Else I would be forced to use If -contructs instead, sure, but just for interest: Is it possible?
2