The document describes a computer graphics lab and contains programs to perform various graphics functions in C++ using graphics libraries. It includes 14 programs to:
1) Draw a line using the DDA algorithm
2) Draw a scenery using 20 graphics functions such as lines, circles, rectangles
3) Draw a circle using Bresenham's circle drawing algorithm
Computer graphics lab report with code in cppAlamgir Hossain
This is the lab report for computer graphics in cpp language. Basically this course is only for the computer science and engineering students.
Problem list:
1.Program for the generation of Bresenham Line Drawing.
2. Program for the generation of Digital Differential Analyzer (DDA) Line Drawing.
3. Program for the generation of Midpoint Circle Drawing.
4. Program for the generation of Midpoint Ellipse Drawing.
5. Program for the generation of Translating an object.
6. Program for the generation of Rotating an Object.
7. Program for the generation of scaling an object.
All programs are coaded in cpp language .
This file contains all the practicals with output regarding GTU syllabus. so it will help to IT and Computer engineering students. It is really knowledgeable so refer these for computer graphics practicals.
Weather service, maps and navigation, photo viewer, instant messaging, web browser, flick list or kinetic scrolling. You want all these with Qt? You get it!
Presentation by Ariya Hidayat held during Qt Developer Days 2009.
http://qt.nokia.com/developer/learning/elearning
Computer graphics lab report with code in cppAlamgir Hossain
This is the lab report for computer graphics in cpp language. Basically this course is only for the computer science and engineering students.
Problem list:
1.Program for the generation of Bresenham Line Drawing.
2. Program for the generation of Digital Differential Analyzer (DDA) Line Drawing.
3. Program for the generation of Midpoint Circle Drawing.
4. Program for the generation of Midpoint Ellipse Drawing.
5. Program for the generation of Translating an object.
6. Program for the generation of Rotating an Object.
7. Program for the generation of scaling an object.
All programs are coaded in cpp language .
This file contains all the practicals with output regarding GTU syllabus. so it will help to IT and Computer engineering students. It is really knowledgeable so refer these for computer graphics practicals.
Weather service, maps and navigation, photo viewer, instant messaging, web browser, flick list or kinetic scrolling. You want all these with Qt? You get it!
Presentation by Ariya Hidayat held during Qt Developer Days 2009.
http://qt.nokia.com/developer/learning/elearning
Computer Graphics in Java and Scala - Part 1bPhilip Schwarz
First see the Scala program from Part 1 translated into Java.
Then see the Scala program modified to produce a more intricate drawing.
Java Code: https://github.com/philipschwarz/computer-graphics-50-triangles-java
Scala Code: https://github.com/philipschwarz/computer-graphics-chessboard-with-a-great-many-squares-scala
This was done as part of my Advertising and Sales Promotion Course. It explains Copywriting and Storyboarding with the help of one of my favorite ADs, 'Dumb Ways to Die'.
Good Governance Leads To Flourish Society & Nation (BS SAP)Neil Mathew
Our 10th Semester BS SAP (Behavioural Science - Social Awareness Program). This included a presentation, a hand-made poster, a survey and a short video.
High Fortune (Product Brand Management)Neil Mathew
A fun little exercise (part of Product Brand Management course) where our group had to design a new product in India. With the little time we had, I think we did alright.
My Presentation on the Corporate Entrepreneurship seen at WIPRO. It starts with a brief idea of how WIPRO started, the opportunities utilized, the challenges faced and how those issues were ingeniously resolved.
This was presented as part of the Corporate Entrepreneurship Course by the B.Tech + MBA batch (Dual Degree) (2010-2015), Amity University, comprising of ACHYUT CHANDRA, NEIL MATHEW, SHIKHAR AGNIHOTRI, SHOUMIK GOSWAMI and UTSAV KHURANA.
Consumer Perception of Job Seekers in updating their Job Profiles on Job PortalsNeil Mathew
The presentation used for my Summer Internship Project Viva.
I did my Internship this year at Monster.com India Pvt Ltd. I conducted a survey and analyzed the results using SmartPLS to assess why Job Seekers do not update their Job Profile Information.
How OLX changed the consumer involvement in the Scrap MarketNeil Mathew
Our Presentation for 'Consumer Behaviour' Class.
Topic: 'How OLX changed the consumer involvement in the Scrap Market'
Group Members: KRATIKA TOMAR, NEIL MATHEW, RAGHAV DUDEJA, SURBHI PURI
The Powerpoint presentation I used for the INK TALK session during the Grand Finale of 'Accenture Innovation Jockeys 3' (Powered by Yahoo).
I was the Category Winner in 'Digital Government', among 1300 entries from about 400 colleges across India.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
2. NEIL MATHEW – 4CS4 – Y3305 - A2324710002
CONTENTS:
Sno: Program Sign
1 WAP using 10 graphics functions.
2 WAP to draw line using DDA Algorithm
3
WAP to draw scenery using 20 graphic
functions.
4 WAP to draw a line using Bresenham's Algo
5 WAP to draw a circle using Bresenham's Algo
6 WAP to draw a circle using Mid-Point Algo
7 WAP to draw an ellipse using Mid-Point Algo
8 WAP to perform Line Clipping
9 WAP to perform scaling of a triangle.
10 WAP to perform translation
11 WAP to perform Scaling w.r.t a Point.
12 WAP to perform rotation w.r.t to a point.
13 WAP to perform reflection w.r.t to a line
14 Project
8.
x=x1; y=y1;
putpixel(x,y,15);
outtextxy(x-15,y-15,"START");
for(int i=1; i<=step; i++)
{
x+=xincrement;
y+=yincrement;
putpixel(x,y,15);
}
outtextxy(x+10,y+10,"END");
}
int main()
{
clrscr();
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"C:/TC/BGI");
int x1,y1,x2,y2;
setbkcolor(DARKGRAY);
cout<<" Enter initial x and y coordinate: ";
cin>>x1>>y1;
cout<<"n Enter final x and y coordinate: ";
cin>>x2>>y2;
cout<<"n Press enter to draw line. ";
getch();
LINE(x1,y1,x2,y2);
getch();
closegraph();
return 2;
}
15.
//Other Pixels:
for(int i=1; i<=steps; i++)
{
while( P > 0 )
{
if(flag==1)
x=x+Sx;
else
y=y+Sy;
P=P-2*dx;
} //END OF WHILE
if(flag==1)
y=y+Sy;
else
x=x+Sx;
P=P+2*dy;
putpixel(x,y,WHITE);
} //END OF FOR
}
void main()
{
int gdriver=DETECT, gmode;
initgraph(&gdriver, &gmode, "C:/TC/BGI");
int x1,x2,y1,y2;
setbkcolor(DARKGRAY);
setcolor(WHITE);
cout<<"n Enter the Initial X Y Coordinate: ";
cin>>x1>>y1;
cout<<"n Enter the Final X Y Coordinate: ";
cin>>x2>>y2;
cout<<"n Press Enter to draw line.";
getch();
outtextxy(x1-10,y1-10, "START");
LINE(x1,y1,x2,y2);
outtextxy(x2+10,y2+10, "END");
getch();
closegraph();
}
17.
Q5: WAP to draw a circle using Bresenham’s Algorithm.
#include <graphics.h>
#include <math.h>
#include <iostream.h>
#include <conio.h>
void otherSpoints(int x, int y,int xc,int yc)
{
putpixel(-x+xc,y+yc,WHITE);
putpixel(x+xc,-y+yc,WHITE);
putpixel(-x+xc,-y+yc,WHITE);
putpixel(y+xc,x+yc,WHITE);
putpixel(-y+xc,x+yc,WHITE);
putpixel(y+xc,-x+yc,WHITE);
putpixel(-y+xc,-x+yc,WHITE);
}
void CIRCLE(int r)
{
int x,y;
int xc=getmaxx()/2;
int yc=getmaxy()/2;
// Plotting the First Point
x=0;
y=r;
putpixel(xc+x,yc+y,WHITE);
// Other Symmetry points:
otherSpoints(x,y,xc,yc);
//Initializing Decision Variable
int d=3-2*r;
//Plotting Other Points of Circle
while(x<y)
{
if(d<0)
{
d=d+4*x+6;
x+=1;
}
else
{
d=d+4*(x-y)+10;
x+=1;
y-=1;
}
putpixel(x+xc,y+yc,WHITE); otherSpoints(x,y,xc,yc);
} //end of while
} //end of function
18.
void main()
{
int gdriver=DETECT, gmode;
initgraph(&gdriver, &gmode, "C:/TC/BGI");
setbkcolor(DARKGRAY);
setcolor(WHITE);
int r;
cout<<"n Enter the radius: ";
cin>>r;
cout<<"n Press Enter to draw Circle.";
getch();
CIRCLE(r);
getch();
closegraph();
}
25. Q8: WAP to perform line clipping.
#include<graphics.h>
#include<iostream.h>
#include<conio.h>
int n; //No of Lines
int ClipWindow[2][2]; //Clipping Window Coordinates
/* For 2 vertices A and C, each having x and y coordinates*/
int Line[20][4]; //Line Coordinates
/* The 20 represents total number of lines possible
and the 4 represents the 4 coordinates required to draw ONE line */
void Draw()
{
clrscr();
int gdriver=DETECT,gmode;
initgraph(&gdriver, &gmode, "C:/TC/BGI");
setbkcolor(BLACK);
setcolor(WHITE);
for(int i=0; i<n; i++)
line(Line[i][0],Line[i][1],Line[i][2],Line[i][3]);
setcolor(CYAN);
rectangle(ClipWindow[0][0],ClipWindow[0][1],ClipWindow[1][0],ClipWindo
w[1][1]);
outtextxy(10,10, "Press any key to continue");
getch(); closegraph();
}
void UnClipped_Input()
{
cout<<"n Enter the number of lines to draw : ";
cin>>n; cout<<endl;
for(int i=0; i<n; i++)
{
cout<<" LINE #"<<(i+1);
cout<<"n Enter the Initial position (x,y) : ";
cin>>Line[i][0];
cin>>Line[i][1];
cout<<" Enter the Final position (x,y) : ";
cin>>Line[i][2];
cin>>Line[i][3];
cout<<"n";
}
cout<<"n >> Enter the coordinates of the Clipping Window:";
cout<<"n >> Vertex A (x,y) : ";
cin>>ClipWindow[0][0];
cin>>ClipWindow[0][1];
cout<<" >> Vertex C (x,y) : ";
cin>>ClipWindow[1][0];
cin>>ClipWindow[1][1];
}
26. long CheckBit(long x,long y)
{
long b=5; /* The 5 here is any random non zero number.
This ensures 0000 doesn't become 0 */
int Xmax= ClipWindow[0][0] > ClipWindow[1][0] ? ClipWindow[0][0] :
ClipWindow[1][0];
int Xmin= ClipWindow[0][0] < ClipWindow[1][0] ? ClipWindow[0][0] :
ClipWindow[1][0];
int Ymax= ClipWindow[0][1] > ClipWindow[1][1] ? ClipWindow[0][1] :
ClipWindow[1][1];
int Ymin= ClipWindow[0][1] < ClipWindow[1][1] ? ClipWindow[0][1] :
ClipWindow[1][1];
//Case 4:
if(x < Xmin)
b=b*10 + 1;
else
b=b*10 + 0;
//Case 3:
if(x > Xmax)
b=b*10 + 1;
else
b=b*10 + 0;
//Case 2:
if(y < Ymin)
b=b*10 + 1;
else
b=b*10 + 0;
//Case 1:
if(y > Ymax)
b=b*10 + 1;
else
b=b*10 + 0;
return b;
}
long AND(long a, long b)
{
//Using manipulated Palindrome Algo
long c;
int digitA;
int digitB;
int digitC[4];
for(int i=3; i>=0; i--)
{
digitA=a%10;
digitB=b%10;
if( digitA==1 && digitB==1)
digitC[i]=1;
else
digitC[i]=0;
a/=10;
b/=10;
}
27. c=5;
for(i=0; i<4; i++)
c=(long) c*10+digitC[i];
return c;
} //END of AND function
void Clip()
{
int Xmax= ClipWindow[0][0] > ClipWindow[1][0] ? ClipWindow[0][0] :
ClipWindow[1][0];
int Xmin= ClipWindow[0][0] < ClipWindow[1][0] ? ClipWindow[0][0] :
ClipWindow[1][0];
int Ymax= ClipWindow[0][1] > ClipWindow[1][1] ? ClipWindow[0][1] :
ClipWindow[1][1];
int Ymin= ClipWindow[0][1] < ClipWindow[1][1] ? ClipWindow[0][1] :
ClipWindow[1][1];
long b1, b2, b1ANDb2;
int i,j,k;
int digit_b1, digit_b2;
double Slope;
for(i=0; i<n; i++)
{ //FOR EACH LINE:
b1=CheckBit(Line[i][0], Line[i][1]);
b2=CheckBit(Line[i][2], Line[i][3]);
b1ANDb2=AND(b1,b2);
if( b1ANDb2 != 50000 ) //OUTSIDE
{
//Remove OUTSIDE Line Coordinates from Array
for(int k=i; k<n-1; k++)
{
Line[k][0]=Line[k+1][0];
Line[k][1]=Line[k+1][1];
Line[k][2]=Line[k+1][2];
Line[k][3]=Line[k+1][3];
}
n--;
i--;
}
else //INSIDE
{
//Completely Inside
if( b1==50000 && b2==50000 )
{
//No Change to be made to Line Coordinates.
}
31. Q9: WAP to perform scaling of a Triangle.
#include<graphics.h>
#include<iostream.h>
#include<conio.h>
int n=4; //Variables for drawpoly() function
int p[8];
int d[8];
int Sx,Sy; //Scaling factors.
void Input()
{
cout<<"n Enter the scaling factor of x:";
cin>>Sx;
cout<<" Enter the scaling factor of y:";
cin>>Sy;
cout<<"n Using default triangle values n | A(0,-20), B(20,-20),
C(20, 20) |";
cout<<"nn Click to Continue... ";
getch();
cleardevice();
p[0]=0;
p[1]=-30;
p[2]=-30;
p[3]=+30;
p[4]=+30;
p[5]=+30;
p[6]=0;
p[7]=-30;
}
void Draw(int Xmid, int Ymid)
{
for(int i=0; i<8; i++)
{
if( i%2==0 )
d[i]=Xmid+p[i];
else
d[i]=Ymid+p[i];
}
drawpoly(n,d);
getch();
}
32. void Scale()
{
int i,j,k;
// Matrix with Triangle Coordinates
int xy1[3][3] = { p[0], p[1], 1,
p[2], p[3], 1,
p[4], p[5], 1,
};
// Matrix with Scaling Factors
int SI[3][3] = { Sx, 0, 0,
0, Sy, 0,
0, 0, 1
};
// Matrix with Coordinates after Scaling.
int XY1[3][3];
//Matrix multiplication: xy1 x SI = XY1
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
XY1[i][j]=0;
for(k=0; k<3; k++)
{
XY1[i][j]+=xy1[i][k]*SI[k][j];
} } }
// Converting Final Matrix into Single Array
k=0;
for(i=0; i<3; i++)
{
for(j=0; j<2; j++) // Till 2 because '1' not needed.
{
p[k++]=XY1[i][j];
}
}
p[k++]=XY1[0][0];
p[k]=XY1[0][1];
}
void main()
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"C:/TC/BGI");
Input();
setcolor(CYAN);
outtextxy(10,getmaxy()*0.25," BEFORE SCALING: ");
Draw(getmaxx()*0.25,getmaxy()*0.5 );
Scale();
setcolor(GREEN);
outtextxy(getmaxx()*0.5,getmaxy()*0.25," AFTER SCALING: ");
Draw(getmaxx()*0.75, getmaxy()*0.5);
closegraph();
}
48.
PROJECT:
TOWN IRRIGATOR (GAME)
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#define UP 72
#define DOWN 80
#define LEFT 75
#define RIGHT 77
#define ESC 27;
///////////GLOBAL VARIABLES////////////
int c,x,y,Xmin,Xmax,Ymin,Ymax;
char ch;
int speed;
int size;
int healthX;
int FLAG_Ob;
int FLAG_ChkPnts[6];
int FLAG_ChkPntsALL;
int COUNT_ChkPnts;
void checkCheckPoint(int, int , int);
void map()
{
//CHECKPOINTS
checkCheckPoint(280,100,0);
checkCheckPoint(210,340,1);
checkCheckPoint(290,365,2);
checkCheckPoint(470,420,3);
checkCheckPoint(60,60,4);
checkCheckPoint(400,70,5);
setcolor(WHITE);
}
49.
///////////CHECK POINT FUNCTION////////////
void checkCheckPoint(int X, int Y, int count)
{
int flag=0,i;
if( ( x > X-5 && x < X+5 ) && ( y > Y-5 && y < Y+5 ) )
{
FLAG_ChkPnts[count] = 1;
setcolor(LIGHTGRAY);
outtextxy(410,25," TOWN IRRIGATED!");
}
if( FLAG_ChkPnts[count] == 0 )
{
setcolor(WHITE);
setfillstyle(SOLID_FILL,RED);
circle(X,Y,6);
floodfill(X,Y,WHITE);
}
else
{
setcolor(WHITE);
setfillstyle(SOLID_FILL,BLUE);
circle(X,Y,6);
floodfill(X,Y,WHITE);
}
for(i=0; i<COUNT_ChkPnts; i++)
{
if( FLAG_ChkPnts[i] !=1 )
{ flag=0; break; }
flag=1;
}
if(flag==1)
{
//CLEARING MESSAGE BOX
setfillstyle(SOLID_FILL,BLACK);
floodfill(410,25,WHITE);
setcolor(GREEN);
outtextxy(430,25, "ALL TOWNS IRRIGATED!");
FLAG_ChkPntsALL=1;
}
}
51.
///////////////MAIN FUNCTION//////////////
void main()
{
int i;
char name;
int flag_CHEAT;
int OXmin,OXmax,OYmin,OYmax;
int gd=DETECT,gm;
FLAG_Ob=0;
COUNT_ChkPnts=6;
speed=9; size=5;
c=0; flag_CHEAT=0;
Xmin=30;
Xmax=490;
Ymin=50;
Ymax=430;
x=Xmin+speed;
y=Ymax-speed;
for(i=0; i<COUNT_ChkPnts; i++)
FLAG_ChkPnts[i]=0;
initgraph(&gd,&gm,"C:/TC/BGI");
/////////////////LOADER SCREEN////////////////
rectangle(50,90,600,300);
outtextxy((getmaxx()*0.5)-100, (getmaxy()*0.5)-130,
"**** TOWN IRRIGATOR ****");
outtextxy((getmaxx()*0.5)-240, (getmaxy()*0.5)-80,
"The Towns in the district have been hit by a severe drought.");
outtextxy((getmaxx()*0.5)-240, (getmaxy()*0.5)-65,
"Due to the scarcity of Water, the population is suffering ! ");
outtextxy((getmaxx()*0.5)-240, (getmaxy()*0.5)-50,
"You can be a HERO, by supplying water to these towns.");
outtextxy((getmaxx()*0.5)-240, (getmaxy()*0.5)-35,
"Irrigate the towns and reach the finish without");
outtextxy((getmaxx()*0.5)-240, (getmaxy()*0.5)-20,
"colliding with the obstacles.");
outtextxy((getmaxx()*0.5)-100, (getmaxy()*0.5)+30,
"Press Any Key when ready...");
getch();
outtextxy((getmaxx()*0.5)-80, (getmaxy()*0.5)+90,
"Loading Map... :)");
sleep(1);
outtextxy((getmaxx()*0.5)-90, (getmaxy()*0.5)+105,
"Building Towns... :)");
sleep(1);
outtextxy((getmaxx()*0.5)-120, (getmaxy()*0.5)+120,
"Cleaning up the Mess... :P");
sleep(1);
delay(10);