Processing Month, Day 28 - Distorted Grids

Posted by Jan Vantomme on 28 May 2011.

Today, we’re going to distort the grid we made yesterday. To do this, we’ll need to modify the algorithm a little bit. We need a multidimensional PVector array to keep track of the points in the grid. We’ll calculate the normal points and use random() to move them away from the grid. The code below shows you how to fill the array.

for (int j 011j++) {
for (int i 011i++) {
= new PVectori*40 random(-1010),
j*40 random(-1010) );

the code for drawing the grid is a little different too. We don’t calculate the points while drawing in this example, we get them out of the PVector array we’ve set up earlier.

for (int j 010++) {
    for (
int i 011i++) {


If we draw the grids with QUAD_STRIP and TRIANGLE_STRIP, they’ll look like this.

A distorted quad strip grid.

A distorted triangle strip grid.


Download the examples to create your own distorted grid.

Tweet this article