If "i+=0.5" is OK, why not "i+=1/2"?

Say I want to draw 2 circles. One followed by another, both spreading out. To make the second circle come behind the first one, I'd use variable i,j like below. This one works as I expect, but when I writej+=1/2 instead of j+=0.5, it doesn't work. What's wrong with the a fraction?

    float i,j=0;

    void setup(){
      size(200,200);
    }
    void draw(){
      ellipse(width/2,height/2,i,i);
      ellipse(width/2,height/2,j,j);
      ++i;
      j+=0.5;
    }
Tagged:

Answers

Sign In or Register to comment.