简体   繁体   中英

Processing 3 / PApplet surface.setSize within Java

I am updating some old script to P3, there is a part where I want to scale the app window to a loaded image size.

As I am working in IntelliJ and so direct in Java I can not directly access surface. Anybody knows how I can call surface.setSize() in a Java Project?

You can still get to the surface variable. Just call the getSurface() function of the PApplet class. If you're extending PApplet , you can just call it directly.

public class MySketch extends PApplet{

   public void mousePressed(){
      getSurface().setSize(200, 200);
   }

   // other functions

}

Also note that if you're loading the image at the beginning, you can just use the settings() function and call size() instead of going through the surface variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM