Category Archives: CG

Implementing Boundary Fill Algorithm in C++

The Boundary Fill Algorithm is a region-filling technique used in computer graphics to fill a connected area with a new colour. Starting from a seed pixel inside the shape, the algorithm recursively colours every neighbouring pixel as long as it does not match the defined boundary colour and has not already been coloured with the new fill colour. It supports 8-connected filling, meaning it spreads to all eight surrounding pixels — including diagonals.

Continue reading Implementing Boundary Fill Algorithm in C++

Implementing Bresenham’s Line Algorithm in C++

Bresenham’s Line Algorithm is one of the most fundamental algorithms in computer graphics. It determines the set of pixels that most closely approximate a straight line between two given endpoints on a raster display. The key advantage of Bresenham’s algorithm over simpler approaches is that it uses only integer arithmetic — no floating-point multiplication or division — making it extremely fast for hardware and software rendering alike.

Continue reading Implementing Bresenham’s Line Algorithm in C++

Implementing 2-D Transformation in C++

2-D Transformations are fundamental operations in computer graphics that change the position, size, or orientation of geometric objects on a 2-D plane. The three basic transformations are Translation (moving an object), Scaling (resizing an object), and Rotation (rotating an object about the origin). This C++ program implements all three transformations on a line segment entered by the user and renders the transformed result using the Turbo C++ graphics.h library.

Continue reading Implementing 2-D Transformation in C++