Skip to content

Projects with C++: Particle swarm animation using SDL, Conway's Game of Life with pgm images, Mandelbrot-Set Fractal draw on bmp images

Notifications You must be signed in to change notification settings

woskar/cpp-projects

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++ Projects

Fractal Draw

The Fractal Drawer draws the Mandelbrot-Set on BMP Images.

mandelsmall

The Mandelbrot set is the set of complex numbers c for which the function f(c)=z^2+c does not diverge. On the pictures, that's the black region inside the shape. It's at the margins of that shape where it gets interesting: The colors indicate how fast the function goes to infinity given each pixel, representing a point in the complex plane, as input.

Code structure:

  • main.cpp: main program connecting the classes
  • fractal.cpp: old version before split up into classes
  • FractalCreator.h: does the actual drawing
  • RGB.h: Color handling
  • Zoom.h: defining a zoom
  • ZoomList.h: stores multiple Zooms in a vector
  • Mandelbrot.h: contains the Math behind the fractal
  • Bitmap.h: Initialize the BMP file
  • BitmapFileHeader: first data in Bitmap
  • BitmapInfoHeader: second data in Bitmap

Created April 2017


Particle Explosion

This program uses the Simple DirectMedia Layer (SDL) to create a window where a swarm of particles performs an explosion-like motion with color-change.

particle_explosion_blue

Detailed instructions on how to create such a simulation can be found in this free udemy-course. For the setup of SDL, see this tutorial. On my mac, I used Homebrew via brew install sdl2 and compiled with g++ including the SDL-files with g++ explosion.cpp -o explosion -I/usr/local/Cellar/sdl2/2.0.5/include/SDL2 -D_THREAD_SAFE -L/usr/local/lib -lSDL2).

Code structure:

  • explosion.cpp: main program connects swarm and screen
  • Screen.h: sdl setup, window management, event handling, blur algorithm
  • Particle.h: particle class initializing and updating position and speed
  • Swarm.h: creates and handles swarm as array of particles

Created April 2017


Game of Life

This project was part of the C++ lecture ipi and is a simple implementation of Conway's Game of Life using the image format PGM (Portable Graymap).

game-of-life

Given an initial configuration of pixels, which correspond to "living cells", the algorithm determines which pixels will be lit in the next iteration. The program outputs a series of pgm-images which can be converted into an animated film using ffmpeg or ImageMagick with the command convert -delay 6 conway_sim_*.pgm simulation.mpg.

The rules are:

  • cell with fewer than two live neighbours dies of isolation
  • cell with two or three live neighbours lives on
  • cell with more than three neighbours dies of overpopulation
  • a dead cell with exactly three live neighbours becomes a live cell

Created March 2017

About

Projects with C++: Particle swarm animation using SDL, Conway's Game of Life with pgm images, Mandelbrot-Set Fractal draw on bmp images

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published