Skip to content

Commit 492d570

Browse files
committed
splitting P2DX tests into separate sketches
1 parent 23f64af commit 492d570

File tree

4 files changed

+86
-6
lines changed

4 files changed

+86
-6
lines changed

debug/apps/fast2d/src/main/java/fast2d/MainActivity.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
import processing.core.PApplet;
1212

1313
public class MainActivity extends AppCompatActivity {
14+
private int TEST = 0; // Basic self-intersecting polygon
15+
// private int TEST = 1; // SVG loading
16+
1417
private PApplet sketch;
1518

1619
@Override
@@ -21,7 +24,15 @@ protected void onCreate(Bundle savedInstanceState) {
2124
setContentView(frame, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
2225
ViewGroup.LayoutParams.MATCH_PARENT));
2326

24-
sketch = new Sketch();
27+
28+
if (TEST == 0) {
29+
sketch = new SketchBasicPoly();
30+
} if (TEST == 1) {
31+
sketch = new SketchSVG();
32+
}
33+
34+
35+
2536
PFragment fragment = new PFragment(sketch);
2637
fragment.setView(frame, this);
2738
}

debug/apps/fast2d/src/main/java/fast2d/Sketch.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313

1414
public class Sketch extends PApplet {
1515
boolean keyboard = false;
16-
17-
static final String P2DX = "processing.opengl.PGraphics2DX";
18-
// static final String P2DX = P2D;
19-
20-
2116
boolean wireframe = false;
2217

2318
int join = MITER, cap = SQUARE, mode = OPEN;
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package fast2d;
2+
3+
import processing.core.PApplet;
4+
import processing.core.PShape;
5+
6+
public class SketchBasicPoly extends PApplet {
7+
float weight = 1;
8+
9+
int join = MITER;
10+
int cap = SQUARE;
11+
int mode = OPEN;
12+
13+
public void settings() {
14+
fullScreen(P2DX);
15+
}
16+
17+
public void setup() {
18+
strokeCap(cap);
19+
strokeJoin(join);
20+
}
21+
22+
public void draw() {
23+
background(255);
24+
25+
fill(255, 0, 63, 127);
26+
stroke(255, 0, 255, 127);
27+
strokeWeight(12 * displayDensity);
28+
strokeJoin(ROUND);
29+
noStroke();
30+
31+
strokeWeight(6 * weight * displayDensity);
32+
stroke(0, 127, 95, 191);
33+
beginShape();
34+
vertex(100, 200);
35+
vertex(200, 100);
36+
vertex(300, 200);
37+
vertex(400, 100);
38+
vertex(350, 200);
39+
vertex(450, 100);
40+
41+
vertex(300, 300);
42+
vertex(mouseX, mouseY);
43+
vertex(600, 200);
44+
45+
vertex(550, 100);
46+
vertex(550, 400);
47+
vertex(750, 400);
48+
vertex(750, 600);
49+
vertex(100, 600);
50+
endShape(mode);
51+
}
52+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package fast2d;
2+
3+
import processing.core.PApplet;
4+
import processing.core.PShape;
5+
6+
public class SketchSVG extends PApplet {
7+
PShape bot;
8+
9+
public void settings() {
10+
fullScreen(P2DX);
11+
}
12+
13+
public void setup() {
14+
bot = loadShape("bot1.svg");
15+
}
16+
17+
public void draw() {
18+
background(102);
19+
shape(bot, 110, 90, 100, 100); // Draw at coordinate (110, 90) at size 100 x 100
20+
shape(bot, 280, 40); // Draw at coordinate (280, 40) at the default size
21+
}
22+
}

0 commit comments

Comments
 (0)