Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PVector a, b, c, d;
- float sz = 8, theta, theta2;
- int frames = 600, dir=1, pos=0, fc=1, fc2;
- PVector[] points = new PVector[frames];
- PVector[] v = new PVector[6];
- boolean save;
- void setup() {
- size(540, 540, P2D);
- smooth(8);
- a = new PVector(50, 500);
- b = new PVector(100, 25);
- c = new PVector(350, 50);
- d = new PVector(500, 350);
- initStuff();
- }
- void draw() {
- background(20);
- strokeWeight(3);
- float l = map(sin(theta-PI/2), -1, 1, 0, 1);
- v[0] = PVector.lerp(a, b, l);
- v[1] = PVector.lerp(b, c, l);
- v[2] = PVector.lerp(c, d, l);
- v[3] = PVector.lerp(v[0], v[1], l);
- v[4] = PVector.lerp(v[1], v[2], l);
- v[5] = PVector.lerp(v[3], v[4], l);
- stroke(#577287);
- drawLine(a, b);
- drawLine(b, c);
- drawLine(c, d);
- stroke(#00bd3a);
- drawLine(v[0], v[1]);
- drawLine(v[1], v[2]);
- stroke(#ffaf18);
- drawLine(v[3], v[4]);
- stroke(#577287);
- fill(255);
- drawEllipse(a);
- drawEllipse(b);
- drawEllipse(c);
- drawEllipse(d);
- stroke(255);
- fill(#577287);
- for (int i=0; i<3; i++) drawEllipse(v[i]);
- fill(#00bd3a);
- for (int i=3; i<5; i++) drawEllipse(v[i]);
- fill(#ffaf18);
- drawEllipse(v[5]);
- points[pos]= v[5].get();
- println(points.length);
- for (int i=0; i<=pos; i++) {
- fill(#ff1935);
- if (i==pos) {
- stroke(255);
- } else {
- noStroke();
- }
- ellipse(points[i].x, points[i].y, sz, sz);
- }
- if (dir>0) {
- pos++;
- } else {
- pos--;
- }
- if ((fc)%((frames/2))==0) {
- dir *=-1;
- }
- theta += TWO_PI/frames;
- theta2 += TWO_PI/(frames/2);
- fc++;
- if (save) {
- if (frameCount%5==0 && frameCount<=(fc2+frames)) saveFrame("image-###.gif");
- }
- if (frameCount>(fc2+frames)) save=false;
- }
- void drawLine(PVector p1, PVector p2) {
- line(p1.x, p1.y, p2.x, p2.y);
- }
- void drawEllipse(PVector p) {
- ellipse(p.x, p.y, sz, sz);
- }
- void initStuff() {
- background(20);
- theta = 0;
- theta2 = 0;
- pos = 0;
- fc = 1;
- dir = 1;
- v = new PVector[6];
- points = new PVector[frames];
- a = new PVector(random(width), random(height));
- b = new PVector(random(width), random(height));
- c = new PVector(random(width), random(height));
- d = new PVector(random(width), random(height));
- }
- void mouseReleased() {
- initStuff();
- }
- void keyPressed() {
- fc2 = frameCount;
- save = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement