FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Examples updated accordingly · ddf/processing@1d39468 · GitHub

Repository navigation

Commit 1d39468

Browse files
committed
Examples updated accordingly
1 parent 3da938c commit 1d39468

18 files changed

Lines changed: 126 additions & 113 deletions

File tree

‎java/examples/Demos/Graphics/Particles/Particle.pde‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ class Particle {
1111

1212
Particle() {
1313
partSize = random(10,60);
14-
part = createShape(QUAD);
14+
part = createShape();
15+
part.beginShape(QUAD);
1516
part.noStroke();
1617
part.texture(sprite);
1718
part.normal(0, 0, 1);
1819
part.vertex(-partSize/2, -partSize/2, 0, 0);
1920
part.vertex(+partSize/2, -partSize/2, sprite.width, 0);
2021
part.vertex(+partSize/2, +partSize/2, sprite.width, sprite.height);
2122
part.vertex(-partSize/2, +partSize/2, 0, sprite.height);
22-
part.end();
23+
part.endShape();
2324

2425
rebirth(width/2,height/2);
2526
lifespan = random(255);
@@ -52,7 +53,7 @@ class Particle {
5253
lifespan = lifespan - 1;
5354
velocity.add(gravity);
5455

55-
part.tint(255,lifespan);
56+
part.setTint(color(255,lifespan));
5657
part.translate(velocity.x, velocity.y);
5758
}
5859
}

‎java/examples/Demos/Graphics/Ribbons/Geometry.pde‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ void createRibbonModel(ArrayList residues, PShape model, ArrayList trj) {
5050

5151
if (renderMode == 0) {
5252
model = createShape();
53+
model.beginShape();
5354
model.stroke(ribbonColor);
5455
model.noFill();
5556
model.beginContour();
@@ -70,12 +71,13 @@ void createRibbonModel(ArrayList residues, PShape model, ArrayList trj) {
7071
model.vertex(posVec.x, posVec.y, posVec.z);
7172
}
7273
model.endContour();
73-
model.end(OPEN);
74+
model.endShape(OPEN);
7475
} else {
7576
// The ribbon construction is fairly inneficient here, since
7677
// it could use triangle strips instead to avoid duplicating
7778
// shared vertices...
78-
model = createShape(TRIANGLES);
79+
model = createShape();
80+
model.beginShape(TRIANGLES);
7981
model.noStroke();
8082
model.fill(ribbonColor);
8183
for (int i = 0; i < vertices.size(); i++) {
@@ -84,7 +86,7 @@ void createRibbonModel(ArrayList residues, PShape model, ArrayList trj) {
8486
model.normal(-normVec.x, -normVec.y, -normVec.z);
8587
model.vertex(posVec.x, posVec.y, posVec.z);
8688
}
87-
model.end();
89+
model.endShape();
8890
}
8991

9092
trj.add(model);

‎java/examples/Demos/Graphics/Trefoil/Surface.pde‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ PShape createTrefoil(float s, int ny, int nx, PImage tex) {
1010
PVector n0, n1, n2;
1111
float u0, u1, v0, v1;
1212

13-
PShape obj = createShape(TRIANGLES);
13+
PShape obj = createShape();
14+
obj.beginShape(TRIANGLES);
1415
obj.texture(tex);
1516

1617
for (int j = 0; j < nx; j++) {
@@ -49,7 +50,7 @@ PShape createTrefoil(float s, int ny, int nx, PImage tex) {
4950
obj.vertex(s * p1.x, s * p1.y, s * p1.z, u1, v0);
5051
}
5152
}
52-
obj.end();
53+
obj.endShape();
5354
return obj;
5455
}
5556

‎java/examples/Demos/Graphics/Wiggling/Wiggling.pde‎

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ public void keyPressed() {
4747
} else if (key == ' ') {
4848
restoreCube();
4949
} else if (key == '1') {
50-
cube.strokeWeight(1);
50+
cube.setStrokeWeight(1);
5151
} else if (key == '2') {
52-
cube.strokeWeight(5);
52+
cube.setStrokeWeight(5);
5353
} else if (key == '3') {
54-
cube.strokeWeight(10);
54+
cube.setStrokeWeight(10);
5555
}
5656
}
5757

@@ -61,9 +61,10 @@ void createCube() {
6161
PShape face;
6262

6363
// Front face
64-
face = createShape(POLYGON);
65-
face.stroke(255, 0, 0);
66-
face.fill(255);
64+
face = createShape();
65+
face.beginShape(POLYGON);
66+
face.stroke(color(255, 0, 0));
67+
face.fill(color(255));
6768
face.beginContour();
6869
face.vertex(-cubeSize/2, -cubeSize/2, +cubeSize/2);
6970
face.vertex(+cubeSize/2, -cubeSize/2, +cubeSize/2);
@@ -79,13 +80,14 @@ void createCube() {
7980
face.vertex(x, y, z);
8081
}
8182
face.endContour();
82-
face.end(CLOSE);
83+
face.endShape(CLOSE);
8384
cube.addChild(face);
8485

8586
// Back face
86-
face = createShape(POLYGON);
87-
face.stroke(255, 0, 0);
88-
face.fill(255);
87+
face = createShape();
88+
face.beginShape(POLYGON);
89+
face.stroke(color(255, 0, 0));
90+
face.fill(color(255));
8991
face.beginContour();
9092
face.vertex(+cubeSize/2, -cubeSize/2, -cubeSize/2);
9193
face.vertex(-cubeSize/2, -cubeSize/2, -cubeSize/2);
@@ -101,13 +103,14 @@ void createCube() {
101103
face.vertex(x, y, z);
102104
}
103105
face.endContour();
104-
face.end(CLOSE);
106+
face.endShape(CLOSE);
105107
cube.addChild(face);
106108

107109
// Right face
108-
face = createShape(POLYGON);
109-
face.stroke(255, 0, 0);
110-
face.fill(255);
110+
face = createShape();
111+
face.beginShape(POLYGON);
112+
face.stroke(color(255, 0, 0));
113+
face.fill(color(255));
111114
face.beginContour();
112115
face.vertex(+cubeSize/2, -cubeSize/2, +cubeSize/2);
113116
face.vertex(+cubeSize/2, -cubeSize/2, -cubeSize/2);
@@ -123,13 +126,14 @@ void createCube() {
123126
face.vertex(x, y, z);
124127
}
125128
face.endContour();
126-
face.end(CLOSE);
129+
face.endShape(CLOSE);
127130
cube.addChild(face);
128131

129132
// Left face
130-
face = createShape(POLYGON);
131-
face.stroke(255, 0, 0);
132-
face.fill(255);
133+
face = createShape();
134+
face.beginShape(POLYGON);
135+
face.stroke(color(255, 0, 0));
136+
face.fill(color(255));
133137
face.beginContour();
134138
face.vertex(-cubeSize/2, -cubeSize/2, -cubeSize/2);
135139
face.vertex(-cubeSize/2, -cubeSize/2, +cubeSize/2);
@@ -145,13 +149,14 @@ void createCube() {
145149
face.vertex(x, y, z);
146150
}
147151
face.endContour();
148-
face.end(CLOSE);
152+
face.endShape(CLOSE);
149153
cube.addChild(face);
150154

151155
// Top face
152-
face = createShape(POLYGON);
153-
face.stroke(255, 0, 0);
154-
face.fill(255);
156+
face = createShape();
157+
face.beginShape(POLYGON);
158+
face.stroke(color(255, 0, 0));
159+
face.fill(color(255));
155160
face.beginContour();
156161
face.vertex(-cubeSize/2, +cubeSize/2, +cubeSize/2);
157162
face.vertex(+cubeSize/2, +cubeSize/2, +cubeSize/2);
@@ -167,13 +172,14 @@ void createCube() {
167172
face.vertex(x, y, z);
168173
}
169174
face.endContour();
170-
face.end(CLOSE);
175+
face.endShape(CLOSE);
171176
cube.addChild(face);
172177

173178
// Bottom face
174-
face = createShape(POLYGON);
175-
face.stroke(255, 0, 0);
176-
face.fill(255);
179+
face = createShape();
180+
face.beginShape(POLYGON);
181+
face.stroke(color(255, 0, 0));
182+
face.fill(color(255));
177183
face.beginContour();
178184
face.vertex(+cubeSize/2, -cubeSize/2, +cubeSize/2);
179185
face.vertex(-cubeSize/2, -cubeSize/2, +cubeSize/2);
@@ -189,7 +195,7 @@ void createCube() {
189195
face.vertex(x, y, z);
190196
}
191197
face.endContour();
192-
face.end(CLOSE);
198+
face.endShape(CLOSE);
193199
cube.addChild(face);
194200
}
195201

‎java/examples/Demos/Performance/CubicGridRetained/CubicGridRetained.pde‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void setup() {
1515
noSmooth();
1616
noStroke();
1717

18-
grid = createShape(PShape.GROUP);
18+
grid = createShape(GROUP);
1919

2020
// Build grid using multiple translations
2121
for (float i =- depth/2+margin; i <= depth/2-margin; i += boxSize){
@@ -25,7 +25,7 @@ void setup() {
2525
// ensures values stay within legal range
2626
boxFill = color(abs(i), abs(j), abs(k), 50);
2727
PShape cube = createShape(BOX, boxSize, boxSize, boxSize);
28-
cube.fill(boxFill);
28+
cube.setFill(boxFill);
2929
cube.translate(k, j, i);
3030
grid.addChild(cube);
3131
}

‎java/examples/Demos/Performance/DynamicParticlesRetained/DynamicParticlesRetained.pde‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@ void setup() {
2323
sprite = loadImage("sprite.png");
2424

2525
for (int n = 0; n < npartTotal; n++) {
26-
PShape part = createShape(QUAD);
26+
PShape part = createShape();
27+
part.beginShape(QUAD);
2728
part.noStroke();
2829
part.texture(sprite);
2930
part.normal(0, 0, 1);
3031
part.vertex(-partSize/2, -partSize/2, 0, 0);
3132
part.vertex(+partSize/2, -partSize/2, sprite.width, 0);
3233
part.vertex(+partSize/2, +partSize/2, sprite.width, sprite.height);
3334
part.vertex(-partSize/2, +partSize/2, 0, sprite.height);
34-
part.end();
35+
part.endShape();
3536
particles.addChild(part);
3637
}
3738

@@ -58,7 +59,7 @@ void draw () {
5859

5960
if (0 <= lifetimes[n]) {
6061
float opacity = 1.0 - float(lifetimes[n]) / partLifetime;
61-
part.tint(255, opacity * 255);
62+
part.setTint(color(255, opacity * 255));
6263

6364
if (lifetimes[n] == 0) {
6465
// Re-spawn dead particle
@@ -73,7 +74,7 @@ void draw () {
7374
velocities[n].y += gravity;
7475
}
7576
} else {
76-
part.tint(0, 0);
77+
part.setTint(color(0));
7778
}
7879
}
7980

‎java/examples/Demos/Performance/StaticParticlesRetained/StaticParticlesRetained.pde‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@ void setup() {
2020
float cy = random(-500, +500);
2121
float cz = random(-500, +500);
2222

23-
PShape part = createShape(QUAD);
23+
PShape part = createShape();
24+
part.beginShape(QUAD);
2425
part.noStroke();
25-
part.tint(255);
26+
part.tint(color(255));
2627
part.texture(sprite);
2728
part.normal(0, 0, 1);
2829
part.vertex(cx - partSize/2, cy - partSize/2, cz, 0, 0);
2930
part.vertex(cx + partSize/2, cy - partSize/2, cz, sprite.width, 0);
3031
part.vertex(cx + partSize/2, cy + partSize/2, cz, sprite.width, sprite.height);
3132
part.vertex(cx - partSize/2, cy + partSize/2, cz, 0, sprite.height);
32-
part.end();
33+
part.endShape();
3334
particles.addChild(part);
3435
}
3536

‎java/examples/Topics/Create Shapes/BeginEndContour/BeginEndContour.pde‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ void setup() {
1111
smooth();
1212
// Make a shape
1313
s = createShape();
14-
s.fill(0);
15-
s.stroke(255);
14+
s.beginShape();
15+
s.fill(0xFF000000);
16+
s.stroke(0xFFFFFFFF);
1617
s.strokeWeight(2);
1718
// Exterior part of shape
1819
s.vertex(-100,-100);
@@ -29,7 +30,7 @@ void setup() {
2930
s.endContour();
3031

3132
// Finishing off shape
32-
s.end(CLOSE);
33+
s.endShape(CLOSE);
3334
}
3435

3536
void draw() {

‎java/examples/Topics/Create Shapes/GroupPShape/GroupPShape.pde‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ void setup() {
1616

1717
// Make a polygon PShape
1818
PShape star = createShape();
19+
star.beginShape();
1920
star.noFill();
20-
star.stroke(255);
21+
star.stroke(0xFFFFFFFF);
2122
star.vertex(0, -50);
2223
star.vertex(14, -20);
2324
star.vertex(47, -15);
@@ -28,23 +29,23 @@ void setup() {
2829
star.vertex(-23, 7);
2930
star.vertex(-47, -15);
3031
star.vertex(-14, -20);
31-
star.end(CLOSE);
32+
star.endShape(CLOSE);
3233

3334
// Make a path PShape
3435
PShape path = createShape();
35-
path = createShape();
36+
path.beginShape();
3637
path.noFill();
37-
path.stroke(255);
38+
path.stroke(0xFFFFFFFF);
3839
for (float a = -PI; a < 0; a += 0.1) {
3940
float r = random(60, 70);
4041
path.vertex(r*cos(a), r*sin(a));
4142
}
42-
path.end();
43+
path.endShape();
4344

4445
// Make a primitive (Rectangle) PShape
4546
PShape rectangle = createShape(RECT,-10,-10,20,20);
46-
rectangle.noFill();
47-
rectangle.stroke(255);
47+
rectangle.setFill(false);
48+
rectangle.setStroke(0xFFFFFFFF);
4849

4950
// Add them all to the group
5051
group.addChild(star);

‎java/examples/Topics/Create Shapes/ParticleSystemPShape/Particle.pde‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ class Particle {
1919
Particle() {
2020
partSize = random(10, 60);
2121
// The particle is a textured quad
22-
part = createShape(QUAD);
22+
part = createShape();
23+
part.beginShape(QUAD);
2324
part.noStroke();
2425
part.texture(sprite);
2526
part.normal(0, 0, 1);
2627
part.vertex(-partSize/2, -partSize/2, 0, 0);
2728
part.vertex(+partSize/2, -partSize/2, sprite.width, 0);
2829
part.vertex(+partSize/2, +partSize/2, sprite.width, sprite.height);
2930
part.vertex(-partSize/2, +partSize/2, 0, sprite.height);
30-
part.end();
31+
part.endShape();
3132

3233
// Initialize center vector
3334
center = new PVector();
@@ -72,7 +73,7 @@ class Particle {
7273
lifespan = lifespan - 1;
7374
// Apply gravity
7475
velocity.add(gravity);
75-
part.tint(255, lifespan);
76+
part.setTint(color(255, lifespan));
7677
// Move the particle according to its velocity
7778
part.translate(velocity.x, velocity.y);
7879
// and also update the center

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL