2222
2323package processing .core ;
2424
25- //import java.awt.Color;
26- //import java.awt.Component;
27-
2825
2926/**
3027 * Surface that's not really visible. Used for PDF and friends, or as a base
3128 * class for other drawing surfaces. It includes the standard rendering loop.
3229 */
3330public class PSurfaceNone implements PSurface {
3431 PApplet sketch ;
32+ PGraphics graphics ;
3533
3634 Thread thread ;
3735 boolean paused ;
@@ -41,7 +39,9 @@ public class PSurfaceNone implements PSurface {
4139 protected long frameRatePeriod = 1000000000L / 60L ;
4240
4341
44- public PSurfaceNone () { }
42+ public PSurfaceNone (PGraphics graphics ) {
43+ this .graphics = graphics ;
44+ }
4545
4646
4747 @ Override
@@ -98,9 +98,27 @@ public void setupExternalMessages() { }
9898 //
9999
100100
101- public void setSize (int width , int height ) {
102- // TODO Auto-generated method stub
101+ @ Override
102+ public void setSize (int wide , int high ) {
103+ if (PApplet .DEBUG ) {
104+ //System.out.format("frame visible %b, setSize(%d, %d) %n", frame.isVisible(), wide, high);
105+ new Exception (String .format ("setSize(%d, %d)" , wide , high )).printStackTrace (System .out );
106+ }
107+
108+ //if (wide == sketchWidth && high == sketchHeight) { // doesn't work on launch
109+ if (wide == sketch .width && high == sketch .height ) {
110+ if (PApplet .DEBUG ) {
111+ new Exception ("w/h unchanged " + wide + " " + high ).printStackTrace (System .out );
112+ }
113+ return ; // unchanged, don't rebuild everything
114+ }
115+
116+ //throw new RuntimeException("implement me, see readme.md");
117+ sketch .width = wide ;
118+ sketch .height = high ;
103119
120+ // set PGraphics variables for width/height/pixelWidth/pixelHeight
121+ graphics .setSize (wide , high );
104122 }
105123
106124
0 commit comments