Last active
December 22, 2019 21:32
-
-
Save GanWeaving/6774583 to your computer and use it in GitHub Desktop.
Orbiting circles
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
| int steps = 40; | |
| Orbiter[] Orb = new Orbiter[steps]; // tmpX, tmpY, tmpOff, tmpDiam, tmpIncr | |
| float r = 0; | |
| float rad, off; | |
| float the = 0; | |
| void setup() { | |
| float x, y; | |
| size(500, 500); | |
| background(0); | |
| stroke(255); | |
| rad = 100; | |
| for (int i = 0; i < int(steps); i++) { | |
| x = width/2 + sin(r) * rad; | |
| y = height/2 + cos(r) * rad; | |
| //off = -TAU*1/(float)steps; | |
| off = noise(frameCount/1000) * -.5*r ; | |
| //off = -r; | |
| fill(255); | |
| noStroke(); | |
| Orb[i]= new Orbiter(x, y, off, 200, 0.03); | |
| r += TAU/steps; | |
| } | |
| } | |
| void draw() { | |
| fill(#27171A); | |
| noStroke(); | |
| rect(0, 0, width, height); | |
| fill(0); | |
| //ellipse(width/2, height/2, width*1, height*1); | |
| for (int i = 0; i < steps; i ++) { | |
| Orb[i].display(); | |
| } | |
| println(the); | |
| the += .03; | |
| if (frameCount % 6 == 0 && frameCount < 211) { | |
| saveFrame("line-####.gif"); | |
| } | |
| if (the > TAU) { | |
| noLoop(); | |
| } | |
| } | |
| class Orbiter { | |
| float diam, incr, offset, x, y, xpos, ypos; | |
| float theta = 0.0; | |
| Orbiter(float tmpX, float tmpY, float tmpOff, float tmpDiam, float tmpIncr) { | |
| offset = tmpOff; | |
| diam = tmpDiam; | |
| xpos = tmpX; | |
| ypos = tmpY; | |
| incr = tmpIncr; | |
| } | |
| void display() { | |
| noFill(); | |
| stroke(255); | |
| //ellipse(xpos, ypos, diam, diam); | |
| fill(255,50); | |
| stroke(255); | |
| strokeWeight(2); | |
| x = xpos + sin(theta+offset)* diam/2; | |
| y = ypos + cos(theta+offset)* diam/2; | |
| ellipse(x, y, 80, 80); | |
| theta += incr; | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment