How to draw smooth concentric circles that can be individually rotated

edited October 2015 in Questions about Code

Hello, I want to draw concentric circles point by point, but if the angle increment between the points is two large, "cracks" or "artifacts" show up on the drawing. However, if I make the angle increment smaller to eliminate the crack or artifacts so the shape is more solid, the time it takes to render the drawing goes up. So there is a trade off. In the code below I attempted a compromise where circles farther out would have angle increments that are smaller than the inner circles so that the drawing goes faster. Am I missing how this sketch could be tweaked, or would an entirely different scheme be appropriate? The goal is to rotate each concentric circle individually quickly in an animation so that I can take a background pattern and do generative art with it. Rules would be written to define how much a circle rotates in each time step based upon the characteristics of the pixels in its neighbors. Right now one frame takes around 3400 ms to complete drawing -- this is too high I think for smooth animation.

    void setup() {
      size(800,800);
    }

    void draw() {
      background(0);
      translate(width/2,height/2);
      stroke(0,255,0);
      int elapsed = millis();

      for (int i = 1; i <= width/2; i++) {
        float ang_step = map(formula(i), 0, formula(width/2), 1 , .1 );
        for (float ang = 0; ang < 360; ang+=ang_step) {
          point(i*cos(radians(ang)),i*sin(radians(ang)));
        }
      }

      println(millis()-elapsed);
    }

    float formula(float i) {
      return i;
    }

Answers

Sign In or Register to comment.