mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Examples updated accordingly
This commit is contained in:
@@ -11,7 +11,8 @@ class Particle {
|
||||
|
||||
Particle() {
|
||||
partSize = random(10,60);
|
||||
part = createShape(QUAD);
|
||||
part = createShape();
|
||||
part.beginShape(QUAD);
|
||||
part.noStroke();
|
||||
part.texture(sprite);
|
||||
part.normal(0, 0, 1);
|
||||
@@ -19,7 +20,7 @@ class Particle {
|
||||
part.vertex(+partSize/2, -partSize/2, sprite.width, 0);
|
||||
part.vertex(+partSize/2, +partSize/2, sprite.width, sprite.height);
|
||||
part.vertex(-partSize/2, +partSize/2, 0, sprite.height);
|
||||
part.end();
|
||||
part.endShape();
|
||||
|
||||
rebirth(width/2,height/2);
|
||||
lifespan = random(255);
|
||||
@@ -52,7 +53,7 @@ class Particle {
|
||||
lifespan = lifespan - 1;
|
||||
velocity.add(gravity);
|
||||
|
||||
part.tint(255,lifespan);
|
||||
part.setTint(color(255,lifespan));
|
||||
part.translate(velocity.x, velocity.y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ void createRibbonModel(ArrayList residues, PShape model, ArrayList trj) {
|
||||
|
||||
if (renderMode == 0) {
|
||||
model = createShape();
|
||||
model.beginShape();
|
||||
model.stroke(ribbonColor);
|
||||
model.noFill();
|
||||
model.beginContour();
|
||||
@@ -70,12 +71,13 @@ void createRibbonModel(ArrayList residues, PShape model, ArrayList trj) {
|
||||
model.vertex(posVec.x, posVec.y, posVec.z);
|
||||
}
|
||||
model.endContour();
|
||||
model.end(OPEN);
|
||||
model.endShape(OPEN);
|
||||
} else {
|
||||
// The ribbon construction is fairly inneficient here, since
|
||||
// it could use triangle strips instead to avoid duplicating
|
||||
// shared vertices...
|
||||
model = createShape(TRIANGLES);
|
||||
model = createShape();
|
||||
model.beginShape(TRIANGLES);
|
||||
model.noStroke();
|
||||
model.fill(ribbonColor);
|
||||
for (int i = 0; i < vertices.size(); i++) {
|
||||
@@ -84,7 +86,7 @@ void createRibbonModel(ArrayList residues, PShape model, ArrayList trj) {
|
||||
model.normal(-normVec.x, -normVec.y, -normVec.z);
|
||||
model.vertex(posVec.x, posVec.y, posVec.z);
|
||||
}
|
||||
model.end();
|
||||
model.endShape();
|
||||
}
|
||||
|
||||
trj.add(model);
|
||||
|
||||
@@ -10,7 +10,8 @@ PShape createTrefoil(float s, int ny, int nx, PImage tex) {
|
||||
PVector n0, n1, n2;
|
||||
float u0, u1, v0, v1;
|
||||
|
||||
PShape obj = createShape(TRIANGLES);
|
||||
PShape obj = createShape();
|
||||
obj.beginShape(TRIANGLES);
|
||||
obj.texture(tex);
|
||||
|
||||
for (int j = 0; j < nx; j++) {
|
||||
@@ -49,7 +50,7 @@ PShape createTrefoil(float s, int ny, int nx, PImage tex) {
|
||||
obj.vertex(s * p1.x, s * p1.y, s * p1.z, u1, v0);
|
||||
}
|
||||
}
|
||||
obj.end();
|
||||
obj.endShape();
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,11 +47,11 @@ public void keyPressed() {
|
||||
} else if (key == ' ') {
|
||||
restoreCube();
|
||||
} else if (key == '1') {
|
||||
cube.strokeWeight(1);
|
||||
cube.setStrokeWeight(1);
|
||||
} else if (key == '2') {
|
||||
cube.strokeWeight(5);
|
||||
cube.setStrokeWeight(5);
|
||||
} else if (key == '3') {
|
||||
cube.strokeWeight(10);
|
||||
cube.setStrokeWeight(10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,9 +61,10 @@ void createCube() {
|
||||
PShape face;
|
||||
|
||||
// Front face
|
||||
face = createShape(POLYGON);
|
||||
face.stroke(255, 0, 0);
|
||||
face.fill(255);
|
||||
face = createShape();
|
||||
face.beginShape(POLYGON);
|
||||
face.stroke(color(255, 0, 0));
|
||||
face.fill(color(255));
|
||||
face.beginContour();
|
||||
face.vertex(-cubeSize/2, -cubeSize/2, +cubeSize/2);
|
||||
face.vertex(+cubeSize/2, -cubeSize/2, +cubeSize/2);
|
||||
@@ -79,13 +80,14 @@ void createCube() {
|
||||
face.vertex(x, y, z);
|
||||
}
|
||||
face.endContour();
|
||||
face.end(CLOSE);
|
||||
face.endShape(CLOSE);
|
||||
cube.addChild(face);
|
||||
|
||||
// Back face
|
||||
face = createShape(POLYGON);
|
||||
face.stroke(255, 0, 0);
|
||||
face.fill(255);
|
||||
face = createShape();
|
||||
face.beginShape(POLYGON);
|
||||
face.stroke(color(255, 0, 0));
|
||||
face.fill(color(255));
|
||||
face.beginContour();
|
||||
face.vertex(+cubeSize/2, -cubeSize/2, -cubeSize/2);
|
||||
face.vertex(-cubeSize/2, -cubeSize/2, -cubeSize/2);
|
||||
@@ -101,13 +103,14 @@ void createCube() {
|
||||
face.vertex(x, y, z);
|
||||
}
|
||||
face.endContour();
|
||||
face.end(CLOSE);
|
||||
face.endShape(CLOSE);
|
||||
cube.addChild(face);
|
||||
|
||||
// Right face
|
||||
face = createShape(POLYGON);
|
||||
face.stroke(255, 0, 0);
|
||||
face.fill(255);
|
||||
face = createShape();
|
||||
face.beginShape(POLYGON);
|
||||
face.stroke(color(255, 0, 0));
|
||||
face.fill(color(255));
|
||||
face.beginContour();
|
||||
face.vertex(+cubeSize/2, -cubeSize/2, +cubeSize/2);
|
||||
face.vertex(+cubeSize/2, -cubeSize/2, -cubeSize/2);
|
||||
@@ -123,13 +126,14 @@ void createCube() {
|
||||
face.vertex(x, y, z);
|
||||
}
|
||||
face.endContour();
|
||||
face.end(CLOSE);
|
||||
face.endShape(CLOSE);
|
||||
cube.addChild(face);
|
||||
|
||||
// Left face
|
||||
face = createShape(POLYGON);
|
||||
face.stroke(255, 0, 0);
|
||||
face.fill(255);
|
||||
face = createShape();
|
||||
face.beginShape(POLYGON);
|
||||
face.stroke(color(255, 0, 0));
|
||||
face.fill(color(255));
|
||||
face.beginContour();
|
||||
face.vertex(-cubeSize/2, -cubeSize/2, -cubeSize/2);
|
||||
face.vertex(-cubeSize/2, -cubeSize/2, +cubeSize/2);
|
||||
@@ -145,13 +149,14 @@ void createCube() {
|
||||
face.vertex(x, y, z);
|
||||
}
|
||||
face.endContour();
|
||||
face.end(CLOSE);
|
||||
face.endShape(CLOSE);
|
||||
cube.addChild(face);
|
||||
|
||||
// Top face
|
||||
face = createShape(POLYGON);
|
||||
face.stroke(255, 0, 0);
|
||||
face.fill(255);
|
||||
face = createShape();
|
||||
face.beginShape(POLYGON);
|
||||
face.stroke(color(255, 0, 0));
|
||||
face.fill(color(255));
|
||||
face.beginContour();
|
||||
face.vertex(-cubeSize/2, +cubeSize/2, +cubeSize/2);
|
||||
face.vertex(+cubeSize/2, +cubeSize/2, +cubeSize/2);
|
||||
@@ -167,13 +172,14 @@ void createCube() {
|
||||
face.vertex(x, y, z);
|
||||
}
|
||||
face.endContour();
|
||||
face.end(CLOSE);
|
||||
face.endShape(CLOSE);
|
||||
cube.addChild(face);
|
||||
|
||||
// Bottom face
|
||||
face = createShape(POLYGON);
|
||||
face.stroke(255, 0, 0);
|
||||
face.fill(255);
|
||||
face = createShape();
|
||||
face.beginShape(POLYGON);
|
||||
face.stroke(color(255, 0, 0));
|
||||
face.fill(color(255));
|
||||
face.beginContour();
|
||||
face.vertex(+cubeSize/2, -cubeSize/2, +cubeSize/2);
|
||||
face.vertex(-cubeSize/2, -cubeSize/2, +cubeSize/2);
|
||||
@@ -189,7 +195,7 @@ void createCube() {
|
||||
face.vertex(x, y, z);
|
||||
}
|
||||
face.endContour();
|
||||
face.end(CLOSE);
|
||||
face.endShape(CLOSE);
|
||||
cube.addChild(face);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user