Stalactite Generator


Carrying on from the last post I have coded another generator in Python, using this idea to simulate the outcome of a natural process by generating stalactites in 2D. The original idea for creating a design process rather than designing an object itself came from seeing them in caves on Grand Cayman, as they are created by a controlled process over hundreds of thousands of years, so I thought it made sense to try to recreate this process myself.

Here are some of the outcome images from the program:

Here’s my code written for Python 2.7, using the idea that a stalactite is essentially an inverted histogram.

import numpy as np
import matplotlib.pyplot as plt
from Tkinter import *

class Application(Frame):
    def __init__(self, master):
        Frame.__init__(self, master)

    def create_widgets(self):
        self.button = Button(self, text = "GENERATE", font = "Helvetica 39", command=self.generator)
        self.button.grid(row=0, column=0, sticky=W)

    def generator(self):
        mu, sigma = 100, 5
        x = mu + sigma * np.random.randn(4000)

        n, bins, patches = plt.hist(x, 50, normed=1, facecolor='black')

        plt.axis([0, 200, 0, 0.09])

root = Tk()
app = Application(root)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s