1+ int join = MITER ;
2+ int cap = SQUARE ;
3+
4+ boolean premultiply = true ;
5+
6+ float dev = 10 ; // deviation
7+
8+ // change these parameters to benchmark various things
9+ int unit = 10 ;
10+ // line, triangle, rect, ellipse, point
11+ int [] amount = { 20 , 15 , 10 , 5 , 40 };
12+
13+ void setup () {
14+ fullScreen(P2DX );
15+ strokeCap (cap);
16+ strokeJoin (join);
17+ PGraphics2DX . premultiplyMatrices = premultiply;
18+
19+ textFont (createFont (" SansSerif" , 15 * displayDensity));
20+ }
21+
22+ public void draw () {
23+ background (255 );
24+
25+ strokeWeight (2 * displayDensity);
26+ stroke (0 );
27+ fill (200 );
28+
29+ for (int i = 0 ; i < amount[0 ]* unit; ++ i) {
30+ float x = random (width );
31+ float y = random (height );
32+ line (x, y, x + random (- dev, dev), y + random (- dev, dev));
33+ }
34+
35+ for (int i = 0 ; i < amount[1 ]* unit; ++ i) {
36+ float x = random (width );
37+ float y = random (height );
38+ triangle (x, y,
39+ x + random (- dev* 2 , dev* 2 ), y + random (- dev* 2 , dev* 2 ),
40+ x + random (- dev* 2 , dev* 2 ), y + random (- dev* 2 , dev* 2 ));
41+ }
42+
43+ for (int i = 0 ; i < amount[2 ]* unit; ++ i) {
44+ rect (random (width ), random (height ), random (dev), random (dev));
45+ }
46+
47+ for (int i = 0 ; i < amount[3 ]* unit; ++ i) {
48+ ellipse (random (width ), random (height ), random (dev* 2 ), random (dev* 2 ));
49+ }
50+
51+ for (int i = 0 ; i < amount[4 ]* unit; ++ i) {
52+ point (random (width ), random (height ));
53+ }
54+
55+ // large ellipse to test smoothness of outline
56+ ellipse (width / 2 , height / 2 , width / 2 , height / 4 );
57+
58+ fill (255 , 0 , 0 );
59+ text ((int ) frameRate + " fps" , 30 , 30 );
60+ }
0 commit comments