Last active
September 16, 2016 04:34
-
-
Save am17an/64d817b740169f9e00d960e073d55480 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
| import peasy.*; | |
| PeasyCam cam; | |
| void setup() { | |
| size(600, 600, P3D); | |
| smooth(8); | |
| cam = new PeasyCam(this, 400); | |
| } | |
| float nPoints = 1000; | |
| float R = 100; | |
| float t = 0; | |
| float xa = 0; | |
| float c = 0; | |
| float frac(float a) { | |
| return a - (float)Math.floor(a); | |
| } | |
| boolean on = false; | |
| float nC = 20; | |
| float nR = 200; | |
| int cFrames = 0; | |
| float delta = 0.03; | |
| float nFrames = HALF_PI/delta; | |
| void draw() { | |
| background(0); | |
| noFill(); | |
| stroke(255); | |
| for (float k = 0; k < nC; ++k) { | |
| pushMatrix(); | |
| float at = map(k, 0, nC, 0, TWO_PI); | |
| float cc = at+t; | |
| if (cc>=TWO_PI) { | |
| while(cc>=TWO_PI) cc-=TWO_PI; | |
| } | |
| float zz = map(cc, 0, TWO_PI, -HALF_PI, HALF_PI); | |
| translate(0, 0, sin(zz)*nR); | |
| R = cos(zz)*nR; | |
| xa = R/10.0*sin(k/10.0+4*t); | |
| c = map(sin(cos(zz) + t), -1, 1, 1, 5); | |
| colorMode(HSB); | |
| strokeWeight(2); | |
| //fill(map(sin(k/10.0 + t), -1, 1, 0, 255), 200, 200); | |
| stroke(238); | |
| beginShape(); | |
| for (float i = 0; i < nPoints; ++i) { | |
| float an = map(i, 0, nPoints, 0, TWO_PI); | |
| float a = map(i, 0, nPoints, 0, TWO_PI*2); | |
| float x = (R)*cos(an); | |
| float y = (R)*sin(an); | |
| float z = map(sin(a), -1, 1, -xa, xa); | |
| //float z = 0; | |
| //println(z); | |
| vertex(x, y, z); | |
| } | |
| // ellipse(0, 0, R, R); | |
| endShape(CLOSE); | |
| popMatrix(); | |
| } | |
| if(on && cFrames < nFrames) { | |
| saveFrame("output/###.gif"); | |
| cFrames += 1; | |
| } | |
| t += delta; | |
| } | |
| void keyPressed() { | |
| if(key =='s') { | |
| on = true; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment