You're probably best off just using the old frame
variable.
For most things like this, you should use the new surface
variable, which is of type PSurface
. You can view the source for PSurface
here. Reading that, we see that unfortunately, the surface
variable doesn't give us access to the frame's position.
Since you can't get to the location from the surface
variable, you have to go a level deeper and get the native component (in the default case, a SmoothCanvas
which extends an awt Canvas
). I figured this out by looking at the source for PSurfaceAWT
available here.
The code for that looks a little gross, since you have to do some casting:
import processing.awt.PSurfaceAWT;
import processing.awt.PSurfaceAWT.SmoothCanvas;
void setup(){
size(200, 200);
}
void draw(){
background(0);
int x = ( (SmoothCanvas) ((PSurfaceAWT)surface).getNative()).getFrame().getX();
text("x: " + x , 20, 20);
}