title: Stream / IntRange over 2D coordinates?
body: <p>I have the following classes:</p>
  
  <pre><code>public class Rectangle
  {
     public int width, height;
     public Point start;
  
     public Rectangle(Point start, int width, int height)
     {
        this.start = start;
        this.width = width;
        this.height = height;
     }
  }
  
  public class Point
  {
     public int x, y;
  
     public Point(int x, int y)
     {
        this.x = x;
        this.y = y;
     }
  }
  </code></pre>
  
  <p>I want to make a method of the Rectangle class such that a Java 8 <code>Stream</code> of type <code>Point</code> is returned where it would stream index locations inside the rectangle. Ex. </p>
  
  <pre><code>// This is inside the rectangle class.
  public Stream&lt;Point&gt; stream(int hstep, int vstep)
  {
     // if the rectangle started at 0,0
     // and had a width and height of 100
     // and hstep and vstep were both 1
     // then the returned stream would be
     // 0,0 -&gt; 1,0 -&gt; 2,0 -&gt; ... -&gt; 100,0 -&gt; 0,1 -&gt; 1,1 -&gt; ...
  
     // If vstep was 5 and h step was 25 it would return
     // 0,0 -&gt; 25,0 -&gt; 50,0 -&gt; 75,0 -&gt; 100,0 -&gt; 0,5 -&gt; 25,5 -&gt; ...
  
     return ...
  }
  </code></pre>
  
  <p>I've used <code>IntStream</code> a lot, <code>map</code>, <code>filter</code>, etc but this is much more complicated then anything I've ever tried. I have no idea how I would do something like that. Can someone steer me int he right direction?</p>