This project represents an independent technical exploration into computer graphics fundamentals, expanding upon the C++/SFML framework provided during Year 1 at Teesside University ("Game Programming Fundamentals"). This was suggested by my lecturer as a challenge to deepen my understanding of SFML and computer graphics algorithms; this tool was adapted from my Cellular Automata Project into an interactive tool for simple 2D graphics. The primary objective was to implement Bresenham's Line Algorithm, bridging the gap between user input and grid-based coordinate systems.
Bresenham's Line Algorithm: Researched and implemented the algorithm, utilising integer-only arithmetic; the tool calculates the most efficient pixel paths between two points in real-time.
Coordinate Space Mapping: Developed a transformation layer to translate continuous Screen Space (mouse coordinates) into a discrete Grid Space (2D array indices). This ensures that user input accurately interacts with the underlying data structure regardless of window size.
Interactive Brush Tool: Engineered dynamic brush logic allowing for real-time drawing.
Brush Scaling: Adjustable multi-pixel brush sizes, done so by drawing to adjacent selected pixels.
Colour State Management: A centralised system to toggle between different pixel states/colours via real-time event polling.
Codebase Refactoring: Adapted an existing cellular automata framework into a functional graphics utility. This involved decoupling the original simulation logic to allow for manual state overrides and custom grid manipulation.
Input Handling & Boundary Validation: Utilised SFML event polling to handle real-time mouse detection, supported by robust boundary checking to prevent array-out-of-bounds errors when drawing near the grid edges.
Language: C++
Libraries/Frameworks: SFML, C++ Standard Libraries (vector, string, algorithm, iostream)
Core Concepts: Computer Graphics (Rasterization), Bresenham’s Line Algorithm, Coordinate Space Mapping (Screen-to-Grid), Input Polling & Event Handling, Codebase Refactoring
IDE: Visual Studio
Tools: GitHub
Implementing a complex algorithm provided significant logic hurdles, along with the challenges that came with the drawing tool itself.
Algorithmic Implementation: The primary challenge was implementing Bresenham’s Line Algorithm from scratch. First ensuring it was fully understood (complex mathematics & error accumulation), before it came to its actual implementation. Whilst it required significant iteration to ensure it fully worked, the time taken to learn the algorithm definitely helped.
Refactoring Simulation to Tooling: Adapting the framework from a previous Cellular Automata Project presented architectural hurdles. I had to decouple the automated "life" logic to allow for manual user overrides. This taught me the importance of modularity; by isolating the grid-writing logic, I was able to repurpose a simulation framework into a functional user utility.
Debugging Coordinate Edge Cases: A persistent challenge involved the multi-pixel brush scaling logic. I encountered a specific bug where using a large brush size in the bottom-right corner (near the UI selection area) would occasionally trigger an index-wrap, causing pixels to be drawn at the top-left of the screen. This highlighted the complexities of coordinate mapping when a single input affects multiple adjacent indices in the array.