01. Write C++ program to draw the following pattern. Use DDA line and Bresenham‘s circle drawing algorithm. Apply the concept of encapsulation
01. Write C++ program to draw the following pattern. Use DDA line and Bresenham‘s circle drawing algorithm. Apply the concept of encapsulation
h>
#include <iostream>
#include <cmath>
using namespace std;
x++;
if (d < 0) {
d += 4 * x + 6;
} else {
y--;
d += 4 * (x - y) + 10;
}
}
}
};
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, (char*)"");
Circle c;
Line l;
// Outer circle
int centerX = 320, centerY = 240, outerRadius = 150, innerRadius = 50;
c.drawCircle(centerX, centerY, outerRadius);
// Inner circle
c.drawCircle(centerX, centerY, innerRadius);
// Triangle vertices
int x1 = centerX, y1 = centerY - outerRadius; // Top vertex
int x2 = centerX - (outerRadius * sin(3.14159 / 3)), y2 = centerY +
(outerRadius / 2); // Bottom left
int x3 = centerX + (outerRadius * sin(3.14159 / 3)), y3 = centerY +
(outerRadius / 2); // Bottom right