Shoebot experiment - perlin noise..

Fri 05 April 2013
By stu

Perlin noise is pretty cool, you can use it to generate realistic looking clouds or mountains.

Here's a bot for shoebot I made a while back that uses perlin noise to generate some nice circles.

You'll need shoebot and the lib "noise" installed into your environment for it to work;

```

pip install noise

```

Then to run;

{: .brush:shell} sbot -w perlin-circlescape1.bot

Here's a video of them in action -

See below the break for the code -

``` {: .brush:python} import noise

size(1000,1000) speed(60)

colormode(HSB)

def setup(): global origx, origy origx = 0 origy = 0

rows = 8 cols = 9 gap = 100

def draw(): global origx, origy, gap

# black background
background(0)

# start from 100,100
translate(100,100)
# and draw the blocks
mx = float(1.0 / WIDTH) * (-MOUSEX - (-WIDTH / 2))
my = float(1.0 / HEIGHT) * (-MOUSEY - (-HEIGHT / 2))

origx += (mx / 8.0)
origy += (my / 8.0)
for gx,gy in grid(rows,cols,1,1):
    # height of each block is determined by x,y coordinates
    n = (noise.pnoise2(float(origx + (gx / 10.0)), float(origy + (gy / 10.0)), 2) / cols)
    diam = 50 + (n * 600.0)
    s = (n * 10.0)
    fill(0.1, 1.0 - s, 1)
    x = gx * gap
    y = gy * gap
    oval(x - diam / 2, y - diam / 2, diam, diam)

```