Giter Club home page Giter Club logo

mandelbrot_fractal's Introduction

MULTI THREAD MANDELBROT FRACTAL [by chunks]

This project was develop for learning reasons and has some know issues.

It is fully writen in english for portfolio reasons.

It aims to build an application which through multiple threads draws a mandelbrot fractal piece (chunk) by piece using xlib to plot the result and pthread to handle the multithreading. The main.cpp file calls the MultiThreadMandelbrotHandler which will orchestrates the resources based on the configurations defined at constants.h. The simple flow to process the result is:

Initialization

Initialize all the needed resources:

X11Config is responsible for setting up the screen and result drawing.

ChunkManager contains two buffers (ThreadQueue) which will store initialChunks and toDrawChunks.

Mandelbrot is the class responsible for the fractal calculation. It iterates until the defined ITERATION_LIMIT and gets a color from ColorPallete to return as result.

Chunks creation

A chunk is a square defined by initial and final dots defined by a processing based on HEIGHT and WIHDHT against CHUNK_SIZE.

Chunks processing

Will iterate on all created chunks and calculate mandelbrot iterations for each pixel and store it at the chunk and move to the toDraw buffer.

This is multithreaded.

Drawing

Will iterate on toDraw buffer and draw each pixel using x11.

This could be multithreaded, but the current implementation brakes with more than 1 thread on the drawer.

Known Issues

  • The chunk quantity limit is already configured, configuring a window bigger than 800x800 or setting chunks smaller than 100 will cause a runtime exception.
  • The drawer cannot be multithreaded, probably due to an error on the mutex usage.

Build

$ cmake -B cmake-build-debug
$ cmake --build cmake-build-debug
$ ./cmake-build-debug/mandelbrot_fractal 

References

PThreads usage

Mandelbrot Calculation

Xlib Usage

mandelbrot_fractal's People

Watchers

James Cloos 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.