# Creating variation in grid with random();

**URL:** <https://discourse.processing.org/t/creating-variation-in-grid-with-random/38175>\
**Category:** Coding Questions\
**Created:** [July 31, 2022, 7:31pm UTC](https://discourse.processing.org/t/creating-variation-in-grid-with-random/38175 "2022-07-31T19:31:10Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![asymmetric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/asymmetric/32/16577_2.png) [@asymmetric](https://discourse.processing.org/u/asymmetric)\
**Post date:** [August 1, 2022, 4:34am UTC](https://discourse.processing.org/t/creating-variation-in-grid-with-random/38175/3 "2022-08-01T04:34:22Z")

</div>

Thank you @glv ! Again, this is exactly what I was looking for. When I follow your directions I end up with a black screen after running the code. What am I missing?

```auto
int cols, rows;

PVector[][] terrain;

void setup()
  {
  size(1000, 1000);  
  terrain = new PVector [30][30];
  
  cols = 20;  
  rows = 20;
  for (int y = 0; y < rows; y++) 
    {
    for (int x = 0; x< cols; x++) 
      {   
      terrain[x][y] = new PVector(x*50 + random(-5, 5), y*50 + random(-5, 5));
      }
    } 
  noLoop();
  }
  
void draw(){
  background(0);
  stroke(255);
  smooth();
  noFill(); 
  
  translate(width/2, height/2); //rotate perspective
  translate(-width/2,-height/2); //perspective 
  
  for (int y = 0; y < rows-1; y++) {
    beginShape(QUAD_STRIP); // OR beginShape(QUAD_STRIP), (TRIANGLE_STRIP)
    for (int x = 0; x< cols; x++) {
      //vertex(x*scl, y*scl, terrain[x][y]);
      //vertex(x*scl, (y+1)*scl, terrain[x][y+1]);
      
       }
         endShape();
    }
}
  

```

---

_[View the full topic](https://discourse.processing.org/t/creating-variation-in-grid-with-random/38175)._
