PPPP
PPPP
CODE
#include <graphics.h>
#include <conio.h>
int main() {
CODE
#include <stdio.h>
#include <math.h>
int main() {
int x1, y1, x2, y2, dx, dy, steps, k;
float xIncrement, yIncrement, x, y;
dx = x2 - x1;
dy = y2 - y1;
x = x1;
y = y1;
return 0;
}
Program Name: - WAP to implement Bresenham’s line drawing Algorithms.
#include <stdio.h>
#include <stdlib.h>
int main() {
int x1, y1, x2, y2, dx, dy, sx, sy, err, e2, currentX, currentY;
dx = abs(x2 - x1);
dy = abs(y2 - y1);
sx = (x1 < x2) ? 1 : -1;
sy = (y1 < y2) ? 1 : -1;
err = dx - dy;
currentX = x1;
currentY = y1;
while (1) {
printf("(%d, %d)\n", currentX, currentY);
e2 = 2 * err;
Output
Program Name: - WAP to draw a line using line() function
CODE
#include <graphics.h>
#include <conio.h>
int main() {
// Initialize the graphics system
int gd = DETECT, gm;
initgraph(&gd, &gm, "");
CODE
#include <graphics.h>
#include <conio.h>
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, ""); // Initialize graphics mode
CODE
#include <graphics.h>
#include <conio.h>
#include <math.h>
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, ""); // Initialize graphics
int x = 0;
int y = radius;
int d = 3 - 2 * radius; // Initial decision parameter
if (d < 0) {
d = d + 4 * x + 6; // Choose East pixel
} else {
d = d + 4 * (x - y) + 10; // Choose South-East pixel
y--; // Move in Y direction
}
x++; // Move in X direction
}
CODE
#include <graphics.h>
#include <conio.h>
#include <math.h>
int main() {
int gd = DETECT, gm;
int x_center = 300; // X coordinate of circle center
int y_center = 300; // Y coordinate of circle center
int radius = 100; // Radius of the circle
getch();
closegraph();
return 0;
}
Output