| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3da938c commit 1d39468
18 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,15 +11,16 @@ class Particle { | |||
| 11 | 11 | ||
| 12 | 12 | Particle() { | |
| 13 | 13 | partSize = random(10,60); | |
| 14 | - part = createShape(QUAD); | ||
| 14 | + part = createShape(); | ||
| 15 | + part.beginShape(QUAD); | ||
| 15 | 16 | part.noStroke(); | |
| 16 | 17 | part.texture(sprite); | |
| 17 | 18 | part.normal(0, 0, 1); | |
| 18 | 19 | part.vertex(-partSize/2, -partSize/2, 0, 0); | |
| 19 | 20 | part.vertex(+partSize/2, -partSize/2, sprite.width, 0); | |
| 20 | 21 | part.vertex(+partSize/2, +partSize/2, sprite.width, sprite.height); | |
| 21 | 22 | part.vertex(-partSize/2, +partSize/2, 0, sprite.height); | |
| 22 | - part.end(); | ||
| 23 | + part.endShape(); | ||
| 23 | 24 | ||
| 24 | 25 | rebirth(width/2,height/2); | |
| 25 | 26 | lifespan = random(255); | |
@@ -52,7 +53,7 @@ class Particle { | |||
| 52 | 53 | lifespan = lifespan - 1; | |
| 53 | 54 | velocity.add(gravity); | |
| 54 | 55 | ||
| 55 | - part.tint(255,lifespan); | ||
| 56 | + part.setTint(color(255,lifespan)); | ||
| 56 | 57 | part.translate(velocity.x, velocity.y); | |
| 57 | 58 | } | |
| 58 | 59 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,6 +50,7 @@ void createRibbonModel(ArrayList residues, PShape model, ArrayList trj) { | |||
| 50 | 50 | ||
| 51 | 51 | if (renderMode == 0) { | |
| 52 | 52 | model = createShape(); | |
| 53 | + model.beginShape(); | ||
| 53 | 54 | model.stroke(ribbonColor); | |
| 54 | 55 | model.noFill(); | |
| 55 | 56 | model.beginContour(); | |
@@ -70,12 +71,13 @@ void createRibbonModel(ArrayList residues, PShape model, ArrayList trj) { | |||
| 70 | 71 | model.vertex(posVec.x, posVec.y, posVec.z); | |
| 71 | 72 | } | |
| 72 | 73 | model.endContour(); | |
| 73 | - model.end(OPEN); | ||
| 74 | + model.endShape(OPEN); | ||
| 74 | 75 | } else { | |
| 75 | 76 | // The ribbon construction is fairly inneficient here, since | |
| 76 | 77 | // it could use triangle strips instead to avoid duplicating | |
| 77 | 78 | // shared vertices... | |
| 78 | - model = createShape(TRIANGLES); | ||
| 79 | + model = createShape(); | ||
| 80 | + model.beginShape(TRIANGLES); | ||
| 79 | 81 | model.noStroke(); | |
| 80 | 82 | model.fill(ribbonColor); | |
| 81 | 83 | for (int i = 0; i < vertices.size(); i++) { | |
@@ -84,7 +86,7 @@ void createRibbonModel(ArrayList residues, PShape model, ArrayList trj) { | |||
| 84 | 86 | model.normal(-normVec.x, -normVec.y, -normVec.z); | |
| 85 | 87 | model.vertex(posVec.x, posVec.y, posVec.z); | |
| 86 | 88 | } | |
| 87 | - model.end(); | ||
| 89 | + model.endShape(); | ||
| 88 | 90 | } | |
| 89 | 91 | ||
| 90 | 92 | trj.add(model); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,7 +10,8 @@ PShape createTrefoil(float s, int ny, int nx, PImage tex) { | |||
| 10 | 10 | PVector n0, n1, n2; | |
| 11 | 11 | float u0, u1, v0, v1; | |
| 12 | 12 | ||
| 13 | - PShape obj = createShape(TRIANGLES); | ||
| 13 | + PShape obj = createShape(); | ||
| 14 | + obj.beginShape(TRIANGLES); | ||
| 14 | 15 | obj.texture(tex); | |
| 15 | 16 | ||
| 16 | 17 | for (int j = 0; j < nx; j++) { | |
@@ -49,7 +50,7 @@ PShape createTrefoil(float s, int ny, int nx, PImage tex) { | |||
| 49 | 50 | obj.vertex(s * p1.x, s * p1.y, s * p1.z, u1, v0); | |
| 50 | 51 | } | |
| 51 | 52 | } | |
| 52 | - obj.end(); | ||
| 53 | + obj.endShape(); | ||
| 53 | 54 | return obj; | |
| 54 | 55 | } | |
| 55 | 56 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,11 +47,11 @@ public void keyPressed() { | |||
| 47 | 47 | } else if (key == ' ') { | |
| 48 | 48 | restoreCube(); | |
| 49 | 49 | } else if (key == '1') { | |
| 50 | - cube.strokeWeight(1); | ||
| 50 | + cube.setStrokeWeight(1); | ||
| 51 | 51 | } else if (key == '2') { | |
| 52 | - cube.strokeWeight(5); | ||
| 52 | + cube.setStrokeWeight(5); | ||
| 53 | 53 | } else if (key == '3') { | |
| 54 | - cube.strokeWeight(10); | ||
| 54 | + cube.setStrokeWeight(10); | ||
| 55 | 55 | } | |
| 56 | 56 | } | |
| 57 | 57 | ||
@@ -61,9 +61,10 @@ void createCube() { | |||
| 61 | 61 | PShape face; | |
| 62 | 62 | ||
| 63 | 63 | // 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)); | ||
| 67 | 68 | face.beginContour(); | |
| 68 | 69 | face.vertex(-cubeSize/2, -cubeSize/2, +cubeSize/2); | |
| 69 | 70 | face.vertex(+cubeSize/2, -cubeSize/2, +cubeSize/2); | |
@@ -79,13 +80,14 @@ void createCube() { | |||
| 79 | 80 | face.vertex(x, y, z); | |
| 80 | 81 | } | |
| 81 | 82 | face.endContour(); | |
| 82 | - face.end(CLOSE); | ||
| 83 | + face.endShape(CLOSE); | ||
| 83 | 84 | cube.addChild(face); | |
| 84 | 85 | ||
| 85 | 86 | // 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)); | ||
| 89 | 91 | face.beginContour(); | |
| 90 | 92 | face.vertex(+cubeSize/2, -cubeSize/2, -cubeSize/2); | |
| 91 | 93 | face.vertex(-cubeSize/2, -cubeSize/2, -cubeSize/2); | |
@@ -101,13 +103,14 @@ void createCube() { | |||
| 101 | 103 | face.vertex(x, y, z); | |
| 102 | 104 | } | |
| 103 | 105 | face.endContour(); | |
| 104 | - face.end(CLOSE); | ||
| 106 | + face.endShape(CLOSE); | ||
| 105 | 107 | cube.addChild(face); | |
| 106 | 108 | ||
| 107 | 109 | // 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)); | ||
| 111 | 114 | face.beginContour(); | |
| 112 | 115 | face.vertex(+cubeSize/2, -cubeSize/2, +cubeSize/2); | |
| 113 | 116 | face.vertex(+cubeSize/2, -cubeSize/2, -cubeSize/2); | |
@@ -123,13 +126,14 @@ void createCube() { | |||
| 123 | 126 | face.vertex(x, y, z); | |
| 124 | 127 | } | |
| 125 | 128 | face.endContour(); | |
| 126 | - face.end(CLOSE); | ||
| 129 | + face.endShape(CLOSE); | ||
| 127 | 130 | cube.addChild(face); | |
| 128 | 131 | ||
| 129 | 132 | // 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)); | ||
| 133 | 137 | face.beginContour(); | |
| 134 | 138 | face.vertex(-cubeSize/2, -cubeSize/2, -cubeSize/2); | |
| 135 | 139 | face.vertex(-cubeSize/2, -cubeSize/2, +cubeSize/2); | |
@@ -145,13 +149,14 @@ void createCube() { | |||
| 145 | 149 | face.vertex(x, y, z); | |
| 146 | 150 | } | |
| 147 | 151 | face.endContour(); | |
| 148 | - face.end(CLOSE); | ||
| 152 | + face.endShape(CLOSE); | ||
| 149 | 153 | cube.addChild(face); | |
| 150 | 154 | ||
| 151 | 155 | // 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)); | ||
| 155 | 160 | face.beginContour(); | |
| 156 | 161 | face.vertex(-cubeSize/2, +cubeSize/2, +cubeSize/2); | |
| 157 | 162 | face.vertex(+cubeSize/2, +cubeSize/2, +cubeSize/2); | |
@@ -167,13 +172,14 @@ void createCube() { | |||
| 167 | 172 | face.vertex(x, y, z); | |
| 168 | 173 | } | |
| 169 | 174 | face.endContour(); | |
| 170 | - face.end(CLOSE); | ||
| 175 | + face.endShape(CLOSE); | ||
| 171 | 176 | cube.addChild(face); | |
| 172 | 177 | ||
| 173 | 178 | // 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)); | ||
| 177 | 183 | face.beginContour(); | |
| 178 | 184 | face.vertex(+cubeSize/2, -cubeSize/2, +cubeSize/2); | |
| 179 | 185 | face.vertex(-cubeSize/2, -cubeSize/2, +cubeSize/2); | |
@@ -189,7 +195,7 @@ void createCube() { | |||
| 189 | 195 | face.vertex(x, y, z); | |
| 190 | 196 | } | |
| 191 | 197 | face.endContour(); | |
| 192 | - face.end(CLOSE); | ||
| 198 | + face.endShape(CLOSE); | ||
| 193 | 199 | cube.addChild(face); | |
| 194 | 200 | } | |
| 195 | 201 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,7 +15,7 @@ void setup() { | |||
| 15 | 15 | noSmooth(); | |
| 16 | 16 | noStroke(); | |
| 17 | 17 | ||
| 18 | - grid = createShape(PShape.GROUP); | ||
| 18 | + grid = createShape(GROUP); | ||
| 19 | 19 | ||
| 20 | 20 | // Build grid using multiple translations | |
| 21 | 21 | for (float i =- depth/2+margin; i <= depth/2-margin; i += boxSize){ | |
@@ -25,7 +25,7 @@ void setup() { | |||
| 25 | 25 | // ensures values stay within legal range | |
| 26 | 26 | boxFill = color(abs(i), abs(j), abs(k), 50); | |
| 27 | 27 | PShape cube = createShape(BOX, boxSize, boxSize, boxSize); | |
| 28 | - cube.fill(boxFill); | ||
| 28 | + cube.setFill(boxFill); | ||
| 29 | 29 | cube.translate(k, j, i); | |
| 30 | 30 | grid.addChild(cube); | |
| 31 | 31 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,15 +23,16 @@ void setup() { | |||
| 23 | 23 | sprite = loadImage("sprite.png"); | |
| 24 | 24 | ||
| 25 | 25 | for (int n = 0; n < npartTotal; n++) { | |
| 26 | - PShape part = createShape(QUAD); | ||
| 26 | + PShape part = createShape(); | ||
| 27 | + part.beginShape(QUAD); | ||
| 27 | 28 | part.noStroke(); | |
| 28 | 29 | part.texture(sprite); | |
| 29 | 30 | part.normal(0, 0, 1); | |
| 30 | 31 | part.vertex(-partSize/2, -partSize/2, 0, 0); | |
| 31 | 32 | part.vertex(+partSize/2, -partSize/2, sprite.width, 0); | |
| 32 | 33 | part.vertex(+partSize/2, +partSize/2, sprite.width, sprite.height); | |
| 33 | 34 | part.vertex(-partSize/2, +partSize/2, 0, sprite.height); | |
| 34 | - part.end(); | ||
| 35 | + part.endShape(); | ||
| 35 | 36 | particles.addChild(part); | |
| 36 | 37 | } | |
| 37 | 38 | ||
@@ -58,7 +59,7 @@ void draw () { | |||
| 58 | 59 | ||
| 59 | 60 | if (0 <= lifetimes[n]) { | |
| 60 | 61 | float opacity = 1.0 - float(lifetimes[n]) / partLifetime; | |
| 61 | - part.tint(255, opacity * 255); | ||
| 62 | + part.setTint(color(255, opacity * 255)); | ||
| 62 | 63 | ||
| 63 | 64 | if (lifetimes[n] == 0) { | |
| 64 | 65 | // Re-spawn dead particle | |
@@ -73,7 +74,7 @@ void draw () { | |||
| 73 | 74 | velocities[n].y += gravity; | |
| 74 | 75 | } | |
| 75 | 76 | } else { | |
| 76 | - part.tint(0, 0); | ||
| 77 | + part.setTint(color(0)); | ||
| 77 | 78 | } | |
| 78 | 79 | } | |
| 79 | 80 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,16 +20,17 @@ void setup() { | |||
| 20 | 20 | float cy = random(-500, +500); | |
| 21 | 21 | float cz = random(-500, +500); | |
| 22 | 22 | ||
| 23 | - PShape part = createShape(QUAD); | ||
| 23 | + PShape part = createShape(); | ||
| 24 | + part.beginShape(QUAD); | ||
| 24 | 25 | part.noStroke(); | |
| 25 | - part.tint(255); | ||
| 26 | + part.tint(color(255)); | ||
| 26 | 27 | part.texture(sprite); | |
| 27 | 28 | part.normal(0, 0, 1); | |
| 28 | 29 | part.vertex(cx - partSize/2, cy - partSize/2, cz, 0, 0); | |
| 29 | 30 | part.vertex(cx + partSize/2, cy - partSize/2, cz, sprite.width, 0); | |
| 30 | 31 | part.vertex(cx + partSize/2, cy + partSize/2, cz, sprite.width, sprite.height); | |
| 31 | 32 | part.vertex(cx - partSize/2, cy + partSize/2, cz, 0, sprite.height); | |
| 32 | - part.end(); | ||
| 33 | + part.endShape(); | ||
| 33 | 34 | particles.addChild(part); | |
| 34 | 35 | } | |
| 35 | 36 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,8 +11,9 @@ void setup() { | |||
| 11 | 11 | smooth(); | |
| 12 | 12 | // Make a shape | |
| 13 | 13 | s = createShape(); | |
| 14 | - s.fill(0); | ||
| 15 | - s.stroke(255); | ||
| 14 | + s.beginShape(); | ||
| 15 | + s.fill(0xFF000000); | ||
| 16 | + s.stroke(0xFFFFFFFF); | ||
| 16 | 17 | s.strokeWeight(2); | |
| 17 | 18 | // Exterior part of shape | |
| 18 | 19 | s.vertex(-100,-100); | |
@@ -29,7 +30,7 @@ void setup() { | |||
| 29 | 30 | s.endContour(); | |
| 30 | 31 | ||
| 31 | 32 | // Finishing off shape | |
| 32 | - s.end(CLOSE); | ||
| 33 | + s.endShape(CLOSE); | ||
| 33 | 34 | } | |
| 34 | 35 | ||
| 35 | 36 | void draw() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,8 +16,9 @@ void setup() { | |||
| 16 | 16 | ||
| 17 | 17 | // Make a polygon PShape | |
| 18 | 18 | PShape star = createShape(); | |
| 19 | + star.beginShape(); | ||
| 19 | 20 | star.noFill(); | |
| 20 | - star.stroke(255); | ||
| 21 | + star.stroke(0xFFFFFFFF); | ||
| 21 | 22 | star.vertex(0, -50); | |
| 22 | 23 | star.vertex(14, -20); | |
| 23 | 24 | star.vertex(47, -15); | |
@@ -28,23 +29,23 @@ void setup() { | |||
| 28 | 29 | star.vertex(-23, 7); | |
| 29 | 30 | star.vertex(-47, -15); | |
| 30 | 31 | star.vertex(-14, -20); | |
| 31 | - star.end(CLOSE); | ||
| 32 | + star.endShape(CLOSE); | ||
| 32 | 33 | ||
| 33 | 34 | // Make a path PShape | |
| 34 | 35 | PShape path = createShape(); | |
| 35 | - path = createShape(); | ||
| 36 | + path.beginShape(); | ||
| 36 | 37 | path.noFill(); | |
| 37 | - path.stroke(255); | ||
| 38 | + path.stroke(0xFFFFFFFF); | ||
| 38 | 39 | for (float a = -PI; a < 0; a += 0.1) { | |
| 39 | 40 | float r = random(60, 70); | |
| 40 | 41 | path.vertex(r*cos(a), r*sin(a)); | |
| 41 | 42 | } | |
| 42 | - path.end(); | ||
| 43 | + path.endShape(); | ||
| 43 | 44 | ||
| 44 | 45 | // Make a primitive (Rectangle) PShape | |
| 45 | 46 | PShape rectangle = createShape(RECT,-10,-10,20,20); | |
| 46 | - rectangle.noFill(); | ||
| 47 | - rectangle.stroke(255); | ||
| 47 | + rectangle.setFill(false); | ||
| 48 | + rectangle.setStroke(0xFFFFFFFF); | ||
| 48 | 49 | ||
| 49 | 50 | // Add them all to the group | |
| 50 | 51 | group.addChild(star); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,15 +19,16 @@ class Particle { | |||
| 19 | 19 | Particle() { | |
| 20 | 20 | partSize = random(10, 60); | |
| 21 | 21 | // The particle is a textured quad | |
| 22 | - part = createShape(QUAD); | ||
| 22 | + part = createShape(); | ||
| 23 | + part.beginShape(QUAD); | ||
| 23 | 24 | part.noStroke(); | |
| 24 | 25 | part.texture(sprite); | |
| 25 | 26 | part.normal(0, 0, 1); | |
| 26 | 27 | part.vertex(-partSize/2, -partSize/2, 0, 0); | |
| 27 | 28 | part.vertex(+partSize/2, -partSize/2, sprite.width, 0); | |
| 28 | 29 | part.vertex(+partSize/2, +partSize/2, sprite.width, sprite.height); | |
| 29 | 30 | part.vertex(-partSize/2, +partSize/2, 0, sprite.height); | |
| 30 | - part.end(); | ||
| 31 | + part.endShape(); | ||
| 31 | 32 | ||
| 32 | 33 | // Initialize center vector | |
| 33 | 34 | center = new PVector(); | |
@@ -72,7 +73,7 @@ class Particle { | |||
| 72 | 73 | lifespan = lifespan - 1; | |
| 73 | 74 | // Apply gravity | |
| 74 | 75 | velocity.add(gravity); | |
| 75 | - part.tint(255, lifespan); | ||
| 76 | + part.setTint(color(255, lifespan)); | ||
| 76 | 77 | // Move the particle according to its velocity | |
| 77 | 78 | part.translate(velocity.x, velocity.y); | |
| 78 | 79 | // and also update the center | |
| Back | FazBrowse Home | New Git URL |
0 commit comments