Last active
August 26, 2022 15:06
-
-
Save guchimon99/a17e88b61cd731fafa8284b5db6c6c37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void pillar (float r, float h) { | |
| push(); | |
| rotateX(HALF_PI); | |
| circle(0, 0, r); | |
| pop(); | |
| push(); | |
| translate(0, h, 0); | |
| rotateX(HALF_PI); | |
| circle(0, 0, r); | |
| pop(); | |
| push(); | |
| translate(0, h / 2, 0); | |
| int count = 32; | |
| float w = TWO_PI * r / count; | |
| for (int i = 0; i < count; i++) { | |
| push(); | |
| rotateY((float)i / count * TWO_PI); | |
| translate(r/2, 0, 0); | |
| rotateY(HALF_PI); | |
| rect(-w / 2, -h / 2, w, h); | |
| pop(); | |
| } | |
| pop(); | |
| } | |
| void protrude (float r, float h) { | |
| float head = r * 1; | |
| push(); | |
| pillar(r, h); | |
| translate(0, h, 0); | |
| sphere(head); | |
| pop(); | |
| } | |
| void coronaVirus (float size) { | |
| sphere(size); | |
| for (int i =0; i < 24; i++) { | |
| push(); | |
| rotateY((float) i / 24 * TWO_PI); | |
| for (int j = 0; j < 48; j++) { | |
| push(); | |
| boolean isSmall = j % 2 == 1; | |
| float r = isSmall ? size / 20 : size / 10; | |
| float h = isSmall ? size / 10 : size / 5; | |
| rotateZ((float) j / 48 * TWO_PI); | |
| translate(0, size, 0); | |
| protrude(r, h); | |
| pop(); | |
| } | |
| pop(); | |
| } | |
| } | |
| void setup () { | |
| size(400, 400, P3D); | |
| } | |
| void draw () { | |
| background(42); | |
| noStroke(); | |
| lights(); | |
| translate(200, 200, 0); | |
| rotateY((float) frameCount / 100 * TWO_PI); | |
| coronaVirus(100); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void pillar (float r, float h) { | |
| push(); | |
| rotateX(HALF_PI); | |
| circle(0, 0, r); | |
| pop(); | |
| push(); | |
| translate(0, h, 0); | |
| rotateX(HALF_PI); | |
| circle(0, 0, r); | |
| pop(); | |
| push(); | |
| translate(0, h / 2, 0); | |
| int count = 16; | |
| float w = TWO_PI * r / count; | |
| for (int i = 0; i < count; i++) { | |
| push(); | |
| rotateY((float)i / count * TWO_PI); | |
| translate(r/2, 0, 0); | |
| rotateY(HALF_PI); | |
| rect(-w / 2, -h / 2, w, h); | |
| pop(); | |
| } | |
| pop(); | |
| } | |
| void protrude (float r, float h) { | |
| float head = r * 1; | |
| push(); | |
| pillar(r, h); | |
| translate(0, h, 0); | |
| sphere(head); | |
| pop(); | |
| } | |
| void coronaVirus (float size) { | |
| sphere(size); | |
| for (int i =0; i < 24; i++) { | |
| push(); | |
| rotateY((float) i / 24 * TWO_PI); | |
| for (int j = 0; j < 48; j++) { | |
| push(); | |
| boolean isSmall = j % 2 == 1; | |
| float r = isSmall ? size / 20 : size / 10; | |
| float h = isSmall ? size / 10 : size / 5; | |
| rotateZ((float) j / 48 * TWO_PI); | |
| translate(0, size, 0); | |
| protrude(r, h); | |
| pop(); | |
| } | |
| pop(); | |
| } | |
| } | |
| void setup () { | |
| size(400, 400, P3D); | |
| } | |
| void draw () { | |
| background(42); | |
| noStroke(); | |
| lights(); | |
| push(); | |
| translate( | |
| 150, | |
| 200 + noise(150, 200 + frameCount, 0) * 10, | |
| 0 | |
| ); | |
| rotateY((float) frameCount / 100 * TWO_PI); | |
| coronaVirus(100); | |
| pop(); | |
| push(); | |
| translate( | |
| 400, | |
| 250 + noise(400, 250 + frameCount, -400) * 10, | |
| -400 | |
| ); | |
| rotateY((float) frameCount / 100 * TWO_PI); | |
| coronaVirus(80); | |
| pop(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment