Skip to content
davidmoreno edited this page May 13, 2011 · 1 revision

Mandelbrot is a simple example that allows the user to navigate through a Mandelbrot set.

The image is calculated by the server, compressed into a PNG and sent to the browser. The most important point on this example is the use of int onion_png_response(unsigned char *image, int Bpp, int width, int height, onion_response *res);

This function just converts a bitmap, with the given bytes per pixel and size to a response. Simple and easy. This way its just a matter of programming you handler to calculate your image, and its sent straight to the user.

As the interface is quite simple there is not much possibility of errors, but in such case it returns the proper error message.

This example is made in C++, which shows that libonion can be used freely on your C++ projects too.

Finally it uses otemplate to embed the html into the executable, although this time there is no data passed to the template, and actually it just copies it there, as there is no processing in the template.

You can see the full example at https://github.com/davidmoreno/onion/blob/master/examples/mandelbrot/

Clone this wiki locally