Emergence

Emergence is a pure graphical, pure functional programming language designed to make images. It is implemented in C++ and can load plugins in runtime. The user can define formulas by connecting nodes in an intuitive user interface.

Yes, I know these features exist already in Blender and a bunch of other programs. Initially, the purpose of this program was to make fractals. I had so much fun and learned so much while making it : now you know why it exists.

Here is a link to the source code repository. You'll need Cmake and Qt5.

How It Works

All the nodes are defined in plugins. The most important ones are X, Y and Output nodes defined in the I/O plugin. These nodes bind different values to each pixel depending on their position in the image. The Output node transforms whatever it takes for each pixel into colors.

For example, the X node binds the leftmost column of pixels to the value 0 and binds the rightmost column of pixels to the value 1. For the columns in between, the binding value is interpolated linearly.

Same thing for the Y node. The lines of pixels are bound between 0 and 1 from top to bottom.

Here is how to multiply X and Y. You connect the Multiply node inputs to X and Y, and connect the Output to the Multiply node. These connections can be done in any order.

The graph is executed recursively from left to right. Each node has a function it uses to update its cache value, then this value is used by the other connected nodes. Wait, did I just say "cache value"? Yes, every node knows what type of value it produces and keeps one as a cache, it also knows if it's valid or not. Every pixel has an ID, and every node knows which pixel ID was used last : no need to invalidate all nodes every time the graph is executed.

For now, there are only 4 types of data a node can keep as cache : real, color, boolean and complex. All 4 can be converted to eachother and are defined in the core of the program. The 4 data types are defined in the same union, so no need to realocate the cache every time it gets converted to another data type.

GUI features

The graphical user interface is implemented using the Qt5 framework. Here are some very basic features I had a lot of fun implementing :

Emergence with FLTK

One day I looked back at the project and realized that I could have had more fun and learned a lot more if I didn't use the Qt framework. Qt5 provides a lot of essential features, which could save a lot of time and effort : but this is not what I was looking for. So I started looking for other toolkits that could replace Qt and settled upon FLTK.

So I rewrote every thing again from scratch including :