CGA PRACTICAL - VII and IX
CGA PRACTICAL - VII and IX
Sheth L.U.J College of Arts & Sir M.V. College of Science and Commerce
Department of Information Technology (Bsc.IT Semester IV)
Computer Graphics and Animation
Practical - VII
Roll No. : 32 Name: SHIVANI NISHAD
Class : SYIT Batch : 2
Date of Assignment : 05/02/2025 Date/Time of Submission : 05/02/2025
7. Solve the following:
a. Perform 2D Rotation on a given object.
CODE:
#include<stdio.h>
#include<graphics.h>
#include<math.h>
int main()
{
int gd=0,gm,x1,y1,x2,y2;
double s,c, angle;
initgraph(&gd, &gm, "C:/TURBOC3/BGI");
setcolor(RED);
printf("Enter coordinates of line: ");
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
cleardevice();
setbkcolor(WHITE);
line(x1,y1,x2,y2);
OUT
getch();
setbkcolor(BLACK);
printf("Enter rotation angle: ");
scanf("%lf", &angle);
setbkcolor(WHITE);
c = cos(angle *3.14/180);
s = sin(angle *3.14/180);
x1 = floor(x1 * c + y1 * s);
y1 = floor(-x1 * s + y1 * c);
x2 = floor(x2 * c + y2 * s);
y2 = floor(-x2 * s + y2 * c);
cleardevice();
line(x1, y1 ,x2, y2);
getch();
closegraph();
return 0;
}
OUTPUT:
Laxmi Charitable Trust’s
Sheth L.U.J College of Arts & Sir M.V. College of Science and Commerce
Department of Information Technology (Bsc.IT Semester IV)
Computer Graphics and Animation
Practical - IX
Roll No. : 32 Name: SHIVANI NISHAD
Class : SYIT Batch : 2
Date of Assignment : 05/02/2025 Date/Time of Submission : 05/02/2025
9. Solve the following:
a. Write a program to fill a circle using Flood Fill Algorithm.
CODE:
#include <stdio.h>
#include <conio.h>
#include <graphics.h>
#include <dos.h>
void main() {
getch();
if (getpixel(x, y) == defaultColor) {
delay(1);
putpixel(x, y, fillColor);
}