Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.LinkedList;
- float[]x, y, a, s;
- int n=4;
- float vel=0.03, velX=1;
- void setup(){
- fullScreen();
- background(0);
- x=new float[n];
- y=new float[n];
- s=new float[n];
- a=new float[n];
- for(int i = 0; i < n; i++){
- s[i]=width/(8*pow(2, i));
- }
- }
- LinkedList<PVector>points=new LinkedList<PVector>();
- LinkedList<PVector>sin1=new LinkedList<PVector>();
- LinkedList<PVector>sin2=new LinkedList<PVector>();
- LinkedList<PVector>sin3=new LinkedList<PVector>();
- LinkedList<PVector>sin4=new LinkedList<PVector>();
- void draw(){
- background(0);
- //alsó
- pushMatrix();
- translate(width/4, height*3/4);
- noFill();
- x[0]=s[0]*cos(a[0]);
- y[0]=s[0]*sin(a[0]);
- strokeWeight(2);
- stroke(255);
- ellipse(0, 0, s[0]*2, s[0]*2);
- line(0, 0, x[0], y[0]);
- for(int i = 1; i < n; i++){
- try{
- x[i]=x[i-1]+s[i]*cos(a[i]);
- y[i]=y[i-1]+s[i]*sin(a[i]);
- strokeWeight(2);
- stroke(255);
- ellipse(x[i-1], y[i-1], s[i]*2, s[i]*2);
- line(x[i-1], y[i-1], x[i], y[i]);
- }catch(Exception ex){}
- }
- for(int i = 0; i < n; i++){
- a[i]+=vel*pow(2, i);
- }
- for(int i = 0; i < points.size(); i++){
- try{
- stroke(200, 0, 0);
- strokeWeight(2);
- line(points.get(i).x, points.get(i).y, points.get(i+1).x, points.get(i+1).y);
- }catch(Exception ex){}
- points.get(i).x+=velX;
- }
- points.add(new PVector(width/4, y[n-1]));
- popMatrix();
- //felső
- pushMatrix();
- translate(width/4, height/4);
- for(int i = 0; i < n; i++){
- strokeWeight(2);
- stroke(255);
- ellipse(0, 0, s[i]*2, s[i]*2);
- try{
- line(0, 0, cos(a[i])*s[i], sin(a[i])*s[i]);
- }catch(Exception ex){}
- }
- for(int i = 0; i < sin1.size(); i++){
- try{
- stroke(0, 200, 0);
- strokeWeight(2);
- line(sin1.get(i).x, sin1.get(i).y, sin1.get(i+1).x, sin1.get(i+1).y);
- }catch(Exception ex){}
- sin1.get(i).x+=velX;
- }
- for(int i = 0; i < sin2.size(); i++){
- try{
- stroke(200, 200, 0);
- strokeWeight(2);
- line(sin2.get(i).x, sin2.get(i).y, sin2.get(i+1).x, sin2.get(i+1).y);
- }catch(Exception ex){}
- sin2.get(i).x+=velX;
- }
- for(int i = 0; i < sin3.size(); i++){
- try{
- stroke(0, 0, 200);
- strokeWeight(2);
- line(sin3.get(i).x, sin3.get(i).y, sin3.get(i+1).x, sin3.get(i+1).y);
- }catch(Exception ex){}
- sin3.get(i).x+=velX;
- }
- for(int i = 0; i < sin4.size(); i++){
- try{
- stroke(200, 0, 200);
- strokeWeight(2);
- line(sin4.get(i).x, sin4.get(i).y, sin4.get(i+1).x, sin4.get(i+1).y);
- }catch(Exception ex){}
- sin4.get(i).x+=velX;
- }
- sin1.add(new PVector(width/4, sin(a[0])*s[0]));
- sin2.add(new PVector(width/4, sin(a[1])*s[1]));
- sin3.add(new PVector(width/4, sin(a[2])*s[2]));
- sin4.add(new PVector(width/4, sin(a[3])*s[3]));
- popMatrix();
- //egyéb
- while(points.size()>500)points.removeFirst();
- while(sin1.size()>500)sin1.removeFirst();
- while(sin2.size()>500)sin2.removeFirst();
- while(sin3.size()>500)sin3.removeFirst();
- while(sin4.size()>500)sin4.removeFirst();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement