0% found this document useful (0 votes)
8 views4 pages

CGA PRACTICAL - VII and IX

The document contains practical assignments for a Computer Graphics and Animation course, focusing on 2D rotation and filling shapes using different algorithms. It includes C code for performing 2D rotation on a line and implementing the Flood Fill and Boundary Fill algorithms for filling shapes. The assignments are submitted by a student named Shivani Nishad from Sheth L.U.J College of Arts & Sir M.V. College of Science and Commerce.

Uploaded by

nshivani829
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

CGA PRACTICAL - VII and IX

The document contains practical assignments for a Computer Graphics and Animation course, focusing on 2D rotation and filling shapes using different algorithms. It includes C code for performing 2D rotation on a line and implementing the Flood Fill and Boundary Fill algorithms for filling shapes. The assignments are submitted by a student named Shivani Nishad from Sheth L.U.J College of Arts & Sir M.V. College of Science and Commerce.

Uploaded by

nshivani829
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

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 - 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 flood(int, int, int, int);

void main() {

​ int gd = DETECT, gm;

​ initgraph(&gd, &gm, "C:/TURBOC3/BGI");

​ rectangle(50, 50, 250, 250);

​ flood(55, 55, 10, 0);

​ getch();

void flood(int x, int y, int fillColor, int defaultColor) {

​ if (getpixel(x, y) == defaultColor) {

​ delay(1);

​ putpixel(x, y, fillColor);

​ flood(x + 1, y, fillColor, defaultColor);

​ flood(x - 1, y, fillColor, defaultColor);

​ flood(x, y + 1, fillColor, defaultColor);

​ flood(x, y - 1, fillColor, defaultColor);

​ }

​ outtextxy(100, 260, "SHIVANI_32");


}

b. Write a program to fill a circle using Boundary Fill Algorithm.


CODE:
#include<graphics.h>
#include<conio.h>

void boundaryFill4(int x, int y, int fill_color, int boundary_color) {


​ if (getpixel(x, y) != boundary_color && getpixel(x, y) != fill_color) {
​ putpixel(x, y, fill_color);
​ delay(4);

​ boundaryFill4(x + 1, y, fill_color, boundary_color);


​ boundaryFill4(x, y+1, fill_color, boundary_color);
​ boundaryFill4(x - 1, y, fill_color, boundary_color);
​ boundaryFill4(x, y - 1, fill_color, boundary_color);
​ outtextxy(200, 300, "SHIVANI_32");
​ }
}
int main() {
​ int gd = DETECT, gm;
​ int x, y, radius;
​ initgraph(&gd, &gm, "C:/TURBOC3/bgi");
​ x = 250;
​ y = 200;
​ radius = 50;
​ setcolor(15);
​ circle(x, y, radius);
​ boundaryFill4(x, y, 6, 15);
​ getch();
​ closegraph();
​ return 0;
​ }

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy