A paint and shapes editor written in C++ with OpenGL/GLUT, built to exercise the whole OOP toolbox: a shape class hierarchy with inheritance, encapsulation, polymorphism, and one deliberate case of multiple inheritance.
A classic MS-Paint-style canvas where every drawable thing is an object. Point is the root of the hierarchy; lines, circles, polygons, and rectangles specialize it. Drawing happens through GLUT mouse callbacks, and every tool and option lives in a right-click context menu.
- Shapes: point, line, rectangle (filled or outline), circle, and regular polygons with 3 to 20 edges (at 20 they visually converge to a circle)
- Brushes: airbrush (4 to 16 px) and a radial brush mode
- Eraser in three sizes
- Undo / redo / clear, from the keyboard or the menu
- 7 colours including a random mode, plus border thickness control (2 to 6 px)
- Everything reachable from a right-click GLUT menu, no toolbar chrome
More sessions:
| Radial brush | All features |
|---|---|
![]() |
![]() |
![]() |
| Key | Action |
|---|---|
q / Esc |
Quit |
c |
Clear the canvas |
+ / - |
Increase / decrease brush or polygon size |
u |
Undo |
r |
Redo |
Colour > Red · Green · Blue · Purple · Yellow · Black · Random
Shapes > Point · Line · Rectangle (Fill/Unfill) · Circle
> Airbrush (4/8/12/16 px) · Polygon (3..20 edges)
Radial Brush > On · Off
Border > 2 · 4 · 5 · 6 px
Eraser > Small · Medium · Large
Undo · Redo · Clear · Quit
This is the point of the project: shapes as a type family.
classDiagram
Point <|-- shape
Point <|-- line
shape <|-- circle
shape <|-- Polygon
Polygon <|-- Rectangle
line <|-- Rectangle
class Point {
-int newX
-int newY
-float newR
-float newG
-float newB
-int s
+getX()
+getY()
+setPosition(x, y)
+setColour(r, g, b)
}
class shape {
#int flag
+setflag(f)
}
class line {
#float sx1
#float sy1
#float sx2
#float sy2
+drawLine(sx, sy, ex, ey)
}
class circle {
#float cx
#float cy
#float px
#float py
+drawCircle(x, y, x1, y1)
}
class Polygon {
#int edges
#int length
#float peri
#float interior
#float exterior
+perimeter()
+int_ext()
+draw_polygon(x1, y1, x2, y2)
}
class Rectangle {
#int dx1
#int dy1
#int dx2
#int dy2
+drawRectangle(x1, y1, x2, y2)
}
- Encapsulation:
Pointkeeps position, colour, and size private behind getters/setters - Inheritance:
shapeadds a curve/polygon flag;circleandPolygonbuild on it - Multiple inheritance:
Rectanglederives from bothPolygonandline, reusing polygon math and line drawing - Polymorphism: every drawn shape decomposes into base-class
Pointobjects held in a singlevector<Point>; undo/redo rewinds and replays ranges of that vector
sudo apt install g++ freeglut3-dev
cd src
make # builds and launches ./PaintThe same makefile detects Darwin and links against the system OpenGL and GLUT frameworks:
cd src
makePaint_OOPS/
├── src/
│ ├── main.cpp # GLUT setup, menus, mouse/keyboard callbacks, undo/redo
│ ├── point.cpp/.h # Point: position, colour, size (root of the hierarchy)
│ ├── shapes.cpp/.h # shape: curve-vs-polygon flag
│ ├── line.cpp/.h # line drawing
│ ├── curve.cpp/.h # circle
│ ├── polygon.cpp/.h # Polygon + Rectangle (multiple inheritance)
│ └── makefile
├── Output/ # Screenshots from real sessions
└── docs/ # Logo + original project presentation (pptx)



