Esempio n. 1
0
    def populate(self, chunk, seed):
        """
        Make smooth waves of stone.
        """

        reseed(seed)

        # And into one end he plugged the whole of reality as extrapolated
        # from a piece of fairy cake, and into the other end he plugged his
        # wife: so that when he turned it on she saw in one instant the whole
        # infinity of creation and herself in relation to it.
        factor = 1 / 1024

        for x, z in product(xrange(16), xrange(16)):
            magx = (chunk.x * 16 + x) * factor
            magz = (chunk.z * 16 + z) * factor

            height = octaves(magx, magz, 5)
            # Normalize around 70. Normalization is scaled according to a
            # rotated cosine.
            scale = rotated_cosine(magx, magz, seed, 16 * 10)
            height *= scale * 30
            height += 70
            for y in xrange(int(height)):
                chunk.set_block((x, y, z), blocks["stone"].slot)
Esempio n. 2
0
import sys

import Image

from beta.simplex import reseed, octaves

WIDTH, HEIGHT = 800, 800

if len(sys.argv) < 6:
    print "Usage: %s <x> <y> <w> <h> <octaves>" % __file__
    sys.exit()

x, y, w, h, depth = (int(i) for i in sys.argv[1:6])

image = Image.new("L", (WIDTH, HEIGHT))
pbo = image.load()

reseed(0)

for i, j in itertools.product(xrange(WIDTH), xrange(HEIGHT)):
    # Get our scaled coords
    xcoord = x + w * i / WIDTH
    ycoord = y + h * j / HEIGHT

    # Get noise and scale from [-1, 1] to [0, 255]
    noise = (octaves(xcoord, ycoord, depth) + 1) * 127.5

    pbo[i, j] = noise

image.save("noise.png")
Esempio n. 3
0
 def test_identity(self):
     for i in range(512):
         self.assertEqual(simplex(i, i), octaves(i, i, 1))