└── Mid point line algorithm.java /Mid point line algorithm.java: -------------------------------------------------------------------------------- 1 | import java.awt.*; 2 | import javax.swing.*; 3 | 4 | public class MidpointCircleDrawing extends JPanel { 5 | 6 | private int centerX, centerY, radius; 7 | 8 | public MidpointCircleDrawing(int centerX, int centerY, int radius) { 9 | this.centerX = centerX; 10 | this.centerY = centerY; 11 | this.radius = radius; 12 | } 13 | 14 | @Override 15 | protected void paintComponent(Graphics g) { 16 | super.paintComponent(g); 17 | drawCircle(g, centerX, centerY, radius); 18 | } 19 | 20 | private void drawCircle(Graphics g, int xc, int yc, int r) { 21 | int x = 0, y = r; 22 | int p = 1 - r; // Initial decision parameter 23 | 24 | plotPoints(g, xc, yc, x, y); 25 | 26 | while (x < y) { 27 | x++; 28 | if (p < 0) { 29 | p += 2 * x + 1; 30 | } else { 31 | y--; 32 | p += 2 * (x - y) + 1; 33 | } 34 | --------------------------------------------------------------------------------