Algorithm Visualizer
After graduating college in 2024, I was a bit bored over the summer as I waited to start my job. Once my boredom hit its peak in July, I decided to build a tiny algorithm visualizer. This is a fairly classic project and I'd never built one until this point, so my thought process was that there's no better time than the present. Let's dive in!
Goals
There were a couple things I wanted to achieve with this project:
- Try out some graphics programming in C++
- Gain a more intuitive understanding of how Dijkstra's Algorithm works
- Stop being bored
Tech Stack
I wanted this project to be as lightweight as I could reasonably get it, so I kept things quite simple.
- C++ — For the uninitiated, C++ is one of the most famously used programming languages in the world.
- SFML — SFML is a C++. multi-media rendering library. In other words, SFML is to C++ what Lego bricks are to plastic.
Structure
The structure of this project is fairly straight forward. I tried to keep logic relatively de-coupled between interactive UI components & the visualizer itself. Thus,
Core/
Algorithm.cpp
Canvas.cpp
Grid.cpp
Node.cpp
Window.cpp
UI/
Button.cpp
Text.cpp
main.cpp
TXTWith that out of the way, let's take a look at how things work.
Entry point
Following the nearly ubiquitous C++ pattern, main.cpp
is the primary entry point to the application. Here, the following actions occur (in order):
- A window object is instantiated from
Core::Window
- Two shared pointers are created referencing
Core::Canvas
andCore::Grid
, respectively. - The grid is initialized and added to the canvas.
- UI components are created under their own shared pointers.
- The canvas & all UI components are added to the window
- The window is started!
TO BE CONTINUED