This JavaFX project demonstrates two classic computer graphics algorithms:
- DDA Line Drawing Algorithm
- Midpoint Circle Drawing Algorithm
These algorithms are used to draw straight lines and perfect circles pixel-by-pixel on a canvas, which is a foundational topic in computer graphics.
This JavaFX application draws a line using the DDA algorithm and a circle using the Midpoint Circle Drawing algorithm on a black canvas.
It uses pixel-level plotting via GraphicsContext.fillRect()
to simulate low-level drawing, just like what happens in OpenGL or raster graphics.
- Calculates
dx
anddy
between two points - Determines the number of steps based on the greater value
- Increments
x
andy
gradually using floating-point arithmetic
- Uses symmetry of a circle to plot 8 points per iteration
- Efficient integer-based algorithm
- Avoids floating-point arithmetic for speed
-
Download or clone the project:
git clone https://github.com/mennadevhub/projectfx.git
-
Make sure you have Java 21 and JavaFX SDK configured.
-
Run GraphicsReport.java in your IDE or via terminal:
javac --module-path javafx-sdk-21.0.7/lib --add-modules javafx.controls src/GraphicsReport.java java --module-path javafx-sdk-21.0.7/lib --add-modules javafx.controls -cp src GraphicsReport