title: Repeated lines/stripes using for loops in Java
body: <p>i want to paint black and white stripes on the image, switching every 20th column both horizontally and vertically on top of an image while staying inside it's borders. so far i can get a black square with 1 pixel wide vertical stripes. i've tried to at least get skinny white stripes on my horizontal lines by switching things around but it's still vertical.</p>
  
  <pre><code>public void zebraStripes() {
  
      Image img = ImageViewer.getImage();
  
      double numPixelsWide = img.getWidth();
      int numPixelsHigh = img.getHeight();
  
  
      Color c = Color.WHITE;
      Color b = Color.BLACK;
  
  
      double i = numPixelsWide;
      if (i % 20 == 0) {
  
          for (int x = 0; x &lt; numPixelsHigh; x++) {
              for (int y = 0; y &lt; i; y++) {
                  img.setPixelColor(y, x, b);
                  }
  
              for (int z = 19; z &lt; i; z = z + 20) {
                      img.setPixelColor(z, x, c);
              }
          }
      }
  }
  
  // paint black and white stripes (left to right) on the image, switching
  // every 20th row
  public void jailBird() {
  
      Image img = ImageViewer.getImage();
  
      double numPixelsWide = img.getWidth();
      double numPixelsHigh = img.getHeight();
  
      Color c = Color.WHITE;
      Color b = Color.BLACK;
  
      double i = numPixelsHigh;
      if (i % 20 == 0) {
  
          for (int x = 0; x &lt; numPixelsHigh; x++) {
              for (int y = 0; y &lt; i; y++) {
                  img.setPixelColor(y, x, b);
                  }
  
              for (int z = 19; z &lt; i; z = z + 20) {
                      img.setPixelColor(z, x, c);
              }
                  }
              }
          }
  
  }
  </code></pre>
  
  <p>how do i get the white stripes to be 20 pixels wide and horizontal?</p>