In [39]:
# raytracing tutorial
# 14 - experiment with opensimplex noise vs random

In [40]:
from opensimplex import OpenSimplex
import numpy
import random
import matplotlib.pyplot as plt

# plot images in this notebook
%matplotlib inline

In [44]:
width = 100
height = 100

In [46]:
# create a numpy array and fill it with random()

img_random = numpy.zeros((width,height))

for x in range(width):
    for y in range(height):
        img_random[x,y] = random.random()
        pass
    pass

plt.imshow(img_random)


Out[46]:
<matplotlib.image.AxesImage at 0x10b62ba90>

In [60]:
# create a numpy array and fill it with opensimplex noise

noise_generator = OpenSimplex()

img_noise = numpy.zeros((width,height))

for x in range(width):
    for y in range(height):
        # notice scaling by 1/5
        img_noise[x,y] =  noise_generator.noise2d(x/5,y/5)
        pass
    pass


plt.imshow(img_noise)


Out[60]:
<matplotlib.image.AxesImage at 0x10fb99a58>

In [ ]: