title: Checkerboard using graphics library
body: <p>I am trying to create an checkerboard with alternating colors. I'm using a vector of rectangles and coloring each individual rectangle.</p>
  
  <pre><code>for (int i=0; i&lt;8; ++i)
      for (int j=0; j&lt;8; ++j)
      {
          grid.push_back(new Rectangle(Point(i*50,j*50),50,50));
          if (i%2==1)
              grid[grid.size()-1].set_fill_color(Color(lemon_chiffon));
          else if (j%2==1)
              grid[grid.size()-1].set_fill_color(Color(moss_green));
  
          if(j%2==1)
              grid[grid.size()-1].set_fill_color(Color(moss_green));
          else if (i%2==0)
              grid[grid.size()-1].set_fill_color(Color(lemon_chiffon));
  </code></pre>
  
  <p>I have tried playing with different values to determine what is colored and the closest I have gotten to a checkerboard was <a href="http://i.imgur.com/AY5TEWS.png" rel="nofollow">this</a>. I know this is a mathematical issue and was hoping someone could help me understand where I am going wrong.</p>