@@ -428,15 +428,20 @@ static public class RendererChangeException extends RuntimeException { }
428
428
429
429
static final String ERROR_MIN_MAX =
430
430
"Cannot use min() or max() on an empty array." ;
431
-
431
+
432
432
boolean insideSettings ;
433
-
433
+
434
434
String renderer = JAVA2D ;
435
-
435
+
436
436
int smooth = 1 ; // default smoothing (whatever that means for the renderer)
437
-
437
+
438
438
boolean fullScreen = false ;
439
439
440
+ // Background default needs to be different from the default value in
441
+ // PGraphics.backgroundColor, otherwise size(100, 100) bg spills over.
442
+ // https://github.com/processing/processing/issues/2297
443
+ int windowColor = 0xffDDDDDD ;
444
+
440
445
441
446
//////////////////////////////////////////////////////////////
442
447
//////////////////////////////////////////////////////////////
@@ -462,7 +467,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
462
467
activity .getWindowManager ().getDefaultDisplay ().getMetrics (dm );
463
468
displayWidth = dm .widthPixels ;
464
469
displayHeight = dm .heightPixels ;
465
-
470
+
466
471
//Setting the default height and width to be fullscreen
467
472
width = displayWidth ;
468
473
height = displayHeight ;
@@ -482,7 +487,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
482
487
// RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.FILL_PARENT);
483
488
//lp.addRule(RelativeLayout.RIGHT_OF, tv1.getId());
484
489
// layout.setGravity(RelativeLayout.CENTER_IN_PARENT);
485
-
490
+
486
491
handleSettings ();
487
492
488
493
int sw = sketchWidth ();
@@ -513,7 +518,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
513
518
"Error: Unsupported renderer class: %s" , rendererName );
514
519
throw new RuntimeException (message );
515
520
}
516
-
521
+
517
522
//set smooth level
518
523
if (smooth == 0 ) {
519
524
g .noSmooth ();
@@ -667,8 +672,8 @@ public void onPause() {
667
672
//}
668
673
// surfaceView.onPause();
669
674
}
670
-
671
-
675
+
676
+
672
677
/**
673
678
* @param method "size" or "fullScreen"
674
679
* @param args parameters passed to the function so we can show the user
@@ -689,16 +694,16 @@ boolean insideSettings(String method, Object... args) {
689
694
}
690
695
throw new IllegalStateException (method + "() cannot be used here, see " + url );
691
696
}
692
-
693
-
697
+
698
+
694
699
void handleSettings () {
695
700
insideSettings = true ;
696
701
//Do stuff
697
702
settings ();
698
703
insideSettings = false ;
699
704
}
700
-
701
-
705
+
706
+
702
707
public void settings () {
703
708
//It'll be empty. Will be overridden by user's sketch class.
704
709
}
@@ -1108,27 +1113,33 @@ public int sketchQuality() {
1108
1113
}
1109
1114
1110
1115
1111
- public int sketchWidth () {
1116
+ final public int sketchWidth () {
1112
1117
if (fullScreen ) {
1113
1118
return displayWidth ;
1114
1119
}
1115
1120
return width ;
1116
1121
}
1117
1122
1118
1123
1119
- public int sketchHeight () {
1124
+ final public int sketchHeight () {
1120
1125
if (fullScreen ) {
1121
1126
return displayHeight ;
1122
1127
}
1123
1128
return height ;
1124
1129
}
1125
1130
1126
1131
1127
- public String sketchRenderer () {
1132
+ final public String sketchRenderer () {
1128
1133
return renderer ;
1129
1134
}
1130
1135
1131
1136
1137
+ final public int sketchWindowColor () {
1138
+ return windowColor ;
1139
+ }
1140
+
1141
+
1142
+
1132
1143
public void orientation (int which ) {
1133
1144
if (which == PORTRAIT ) {
1134
1145
activity .setRequestedOrientation (ActivityInfo .SCREEN_ORIENTATION_PORTRAIT );
@@ -1540,8 +1551,8 @@ public void draw() {
1540
1551
// layout.invalidate();
1541
1552
// }
1542
1553
// }
1543
-
1544
-
1554
+
1555
+
1545
1556
/**
1546
1557
* Create a full-screen sketch using the default renderer.
1547
1558
*/
@@ -1619,8 +1630,8 @@ public void size(int iwidth, int iheight, String irenderer) {
1619
1630
}
1620
1631
}
1621
1632
}
1622
-
1623
-
1633
+
1634
+
1624
1635
//. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1625
1636
1626
1637
@@ -1694,7 +1705,7 @@ public void size(final int iwidth, final int iheight,
1694
1705
final String irenderer , final String ipath ) {
1695
1706
if (iwidth != this .width || iheight != this .height ||
1696
1707
!this .renderer .equals (irenderer )) {
1697
- if (insideSettings ("size" , iwidth , iheight , irenderer ,
1708
+ if (insideSettings ("size" , iwidth , iheight , irenderer ,
1698
1709
ipath )) {
1699
1710
this .width = iwidth ;
1700
1711
this .height = iheight ;
@@ -3653,8 +3664,8 @@ static public void println(Object what) {
3653
3664
}
3654
3665
}
3655
3666
}
3656
-
3657
-
3667
+
3668
+
3658
3669
/**
3659
3670
* @webref output:text_area
3660
3671
* @param what one-dimensional array
@@ -8144,6 +8155,21 @@ public void normal(float nx, float ny, float nz) {
8144
8155
}
8145
8156
8146
8157
8158
+ public void attrib (String name , float ... values ) {
8159
+ g .attrib (name , values );
8160
+ }
8161
+
8162
+
8163
+ public void attrib (String name , int ... values ) {
8164
+ g .attrib (name , values );
8165
+ }
8166
+
8167
+
8168
+ public void attrib (String name , boolean ... values ) {
8169
+ g .attrib (name , values );
8170
+ }
8171
+
8172
+
8147
8173
/**
8148
8174
* Set texture mode to either to use coordinates based on the IMAGE
8149
8175
* (more intuitive for new users) or NORMALIZED (better for advanced chaps)
@@ -8255,11 +8281,12 @@ public PShape loadShape(String filename) {
8255
8281
}
8256
8282
8257
8283
8258
- public PShape createShape (PShape source ) {
8259
- return g .createShape (source );
8260
- }
8261
-
8262
-
8284
+ /**
8285
+ * @webref shape
8286
+ * @see PShape
8287
+ * @see PShape#endShape()
8288
+ * @see PApplet#loadShape(String)
8289
+ */
8263
8290
public PShape createShape () {
8264
8291
return g .createShape ();
8265
8292
}
@@ -8270,6 +8297,10 @@ public PShape createShape(int type) {
8270
8297
}
8271
8298
8272
8299
8300
+ /**
8301
+ * @param kind either POINT, LINE, TRIANGLE, QUAD, RECT, ELLIPSE, ARC, BOX, SPHERE
8302
+ * @param p parameters that match the kind of shape
8303
+ */
8273
8304
public PShape createShape (int kind , float ... p ) {
8274
8305
return g .createShape (kind , p );
8275
8306
}
0 commit comments