Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Rotor r;
- float timer = 0;
- int mode;
- void setup() {
- size(1000,600);
- smooth();
- noFill();
- frameRate(60);
- background(255);
- mode = 1;
- r = new Rotor(random(width/2)+100,random(height/2)+100,random(40,100));
- }
- void draw() {
- noStroke();
- fill( 255,255,255, 10 );
- rect(0,0,width,height);
- noFill();
- float t = frameCount / 100.0;
- timer = timer + frameRate/1000;
- r.drawRotor(mode);
- if(timer > timeLimit()){
- timer = 0;
- if(mode != 1){
- //background(255);
- float newR = random(40,100);
- float newX = r.centerX + cos(r.angle) * (r.radius - newR);
- float newY = r.centerY + sin(r.angle) * (r.radius - newR);
- r.newPos(newX, newY);
- r.radius = newR;
- }
- mode *= -1;
- }
- }
- float timeLimit(){
- float timeLimit = random(50);
- return timeLimit;
- }
- class Rotor {
- color c;
- int thickness;
- float xPoint;
- float yPoint;
- float radius;
- float angle = 0;
- float centerX;
- float centerY;
- Rotor(float cX, float cY, float rad) {
- c = color(0);
- thickness = 1;
- centerX = cX;
- centerY = cY;
- radius = rad;
- }
- void newPos(float x, float y){
- centerX = x;
- centerY = y;
- }
- void drawRotor(int mode) {
- stroke(c);
- strokeWeight(thickness);
- if(mode == 1){
- angle += frameRate/1000;
- }else{
- radius += 2;
- }
- xPoint = centerX + cos(angle) * radius;
- yPoint = centerY + sin(angle) * radius;
- ellipse(xPoint, yPoint,thickness,thickness);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement