GithubHelp home page GithubHelp logo

blindquarter's Introduction

BlindQuarter - Multi-Scale Turing Patterns

Hackaday project

Description

There are many visual patterns that occur naturally: zebra stripes, leopard spots, tribal tattoos... Ah well, maybe not the last one. Anyway, it turns out that some of these patterns can be described mathematically and computer-simulated. Starting with a grid of pixels of random values, and applying a simple set of rules over and over again, you see unexpected patterns emerge. Maybe you know Conway's game of life, that's the same kind of idea. Right now we're interested in Turing patterns, or reaction-diffusion patterns, which have been first described by Alan Turing.

History

Jonathan McCabe published an algorithm to generate "Cyclic Symmetric Multi-Scale Turing Patterns". Multi-scale because the patterns exist and evolve at different levels and at different timesteps (e.g. small wobbly mazes wobbling along with big wobbly mazes), and cyclic-symmetric because there's some circular averaging involved in the process, which gives a kind of mandala feeling to the generated pictures.

His published pictures and the videos that can be created with his algorithm are amazing. Think of a Windows Media Player visualization who quit her job and started doing LSD and listening to aggrotech. McCabe was nice enough to give lots of additional details about his algorithm to Jason Rampe, who published them in this blog post. Originally, I became aware of McCabe's work thanks to that post by Frederik Vanhoutte.

Some developers have already put their implementation online, see for instance this and that. I wanted to write my own so I can really understand the algorithm and play with it to discover different kinds of patterns (hopefully). At first I tried in Python, because I'm learning it so I thought it would be a good exercise. It was, but the generation was also really, really slow. Then I worked with C because that's the language I know best. At that time, the program generated images using the gifsave89 library.

Because I wasn't satisfied with generating GIFs, I switched to SDL for displaying the generated images and adapted the rest of the program to C++. I don't have a lot of experience with C++ and I mostly learn as I go, so the code is really C with some C++ features that were useful to me.

Documentation

The documentation is generated with Doxygen. To understand the main algorithm, everything that you need to know is explained in the abovementioned blog post, although I combined some generation steps to streamline the code a bit.

Make & run

You need SDL to compile, and you might have to adapt the Makefile to your installation path (values SDL_LIB and SDL_INCLUDE). After make all, make run starts the generation with standard parameters. The command line arguments are the image width, height, and the colormap. Just run the executable without arguments to show usage info. The other pattern parameters are hard-coded for the moment.

Once the SDL window is open, the generation starts with a single pattern. The numpad keys '+' and '-' add and remove a pattern, respectively. Clicking in the window resets the image.

blindquarter's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.