Académique Documents
Professionnel Documents
Culture Documents
INDEX
Sr.No 1. 2. 3. 4. 5. 6. 7. 8. 9. 10 11. 12. 13. Topic Introduction to Computer Graphics Applications of Computer Graphics Inbuilt Functions in Computer Graphics Program to draw line with direct method Program to draw line with Bresenham Line Algorithm Program to draw line with Direct Differential Algorithm Program to draw a circle with Direct Method Program to draw circle with Bresenham Circle Algorithm Program to draw circle with Midpoint Circle Algorithm Program to draw circle with Polar Algorithm Program to draw ellipse with Polynomial Algorithm Program to draw ellipse with Polar Algorithm Programs of 2D Transformations. Program to show the Translation of a line Program to show the Scaling Transformation Program to show the Rotation of an object Program to show the Reflection Transformation Program to show Shearing Transformation 14. Programs of Seven Applications Page No. 3 4 7 10 12 14 16 18 20 22 24 26 28 28 30 31 32 34 36
the representation and manipulation of image data by a computer the various technologies used to create and manipulate images the images so produced, and the sub-field of computer science which studies methods for digitally synthesizing and manipulating visual content, see study of computer graphics Computer graphics is the life line of today's computer world. Today, computers and computer-generated images touch many aspects of daily life. Computer imagery is found on television, in newspapers, for example in weather reports, or for example in all kinds of medical investigation and surgical procedures. A well-constructed graph can present complex statistics in a form that is easier to understand and interpret. Computer generated imagery can be categorized into several different types: 2D, 3D, 5D, and animated graphics. As technology has improved, 3D computer graphics have become more common, but 2D computer graphics are still widely used. Computer graphics has emerged as a sub-field of computer science
2D Computer Graphics
2D computer graphics are the computer-based generation of digital imagesmostly from twodimensional models, such as 2D geometric models, text, and digital images, and by techniques specific to them. The word may stand for the branch of computer science that comprises such techniques, or for the models themselves. 2D computer graphics are mainly used in applications that were originally developed upon traditional printing and drawing technologies, such as typography, cartography, technical drawing, advertising, etc.. In those applications, the two-dimensional image is not just a representation of a real-world object, but an independent artifact with added semantic value; twodimensional models are therefore preferred, because they give more direct control of the image than 3D computer graphics, whose approach is more akin to photography than to typography.
Computer Animation
Computer animation is the art of creating moving images via the use of computers. It is a subfield of computer graphics and animation. Increasingly it is created by means of 3D computer graphics, though 2D computer graphics are still widely used for stylistic, low bandwidth, and faster real-time rendering needs. Sometimes the target of the animation is the computer itself, but sometimes the target is another medium, such as film. It is also referred to as CGI (Computergenerated imagery or computer-generated imaging), especially when used in films.
Visualization
Visualization is the process of rendering data as images in order to enhance our understanding. The idea is not new: maps are visualizations of terrain and since the early days of printing graphs and charts have been used to represent both empirical data and mathematical functions. Although visualization is used in nearly all fields of human Endeavour where computers may be used to process and display data, it's fair to say that the technique is used to the greatest extent in the commercial and scientific worlds.
Business Graphics
This term covers charts and graphs that represent economic statistics and which are generally used by managers in both in the public and private sectors. In particular, business visualization is used in analysis, to extract meaning from data, and for presentation, to explain data to an audience. The use of images in economics considerably predates the computer age, but of course computers enable the production of many kinds of highly effective and colorful charts from raw data in seconds; as a result a thriving market in presentation software exists.
Entertainment
Computer Graphics can be seen commonly used in music videos, television advertisement, animation pictures and various movies. Computer graphic techniques are used in these applications to produce transformation of one object into another, the process called morphing. Virtually every game on the computer uses computer graphics or animation. This includes
Image Processing
Image processing is manipulation of images with the help of computers. Some of the algorithms used in image processing include thinning or skeletonisation, edge detection and contrast enhancement. These are usually implemented in software but may also use special purpose hardware for speed. Image processing contrasts with computer graphics, which is usually more concerned with the generation of artificial images, and visualization, which attempts to understand real-world data by displaying it as an artificial image.
Virtual Reality
Virtual reality is a way for humans to visualize, manipulate and interact with computers and extremely complex data. The visualization part refers to the computer generating visual, auditory or other sensual outputs to the user of a world within the computer. This world may ne CAD model, a scientific simulation, or a view into a database. The user can interact with the world and directly manipulate objects within the world. Interaction with the virtual world, at least with near real time control of the viewpoint, in my opinion, is a critical test for a virtual reality.
Cartography
Computer Graphics is used to produce both accurate representations of geographical maps etc., Exploration maps for drilling and mining, Whether maps and Population density maps.
Example: line(20,10,30,40); Here x1 should be less than x2 and y1 should be less than y2. 2. To draw an arc: To draw an arc we have an arc function. It has five parameters x1, y1, staring angle, ending angle, and radius. Syntax: arc(x1, y1, starting angle, ending angle, radius); Example: arc(20,30,90,180,50); 3. To draw circle: to draw circle we have an inbuilt function with three parameters x centre, y centre and radius. Syntax: circle(x centre, y centre, radius); Example: circle(100,200,50);
Settextstyle (TRIPLEX_FONT,0,7); By default direction is horizontal . y horizontal-> 0 y vertical-> 1 y size limit-> 0-15 8. To set style of a line: to set style of a line we use set line style function having three parameters style, unsigned pattern, and thickness. By default line is dotted in nature. y horizontal-> 0 y vertical-> 1 y thickness range-> 0-1 Syntax: setlinestyle(style, Unsigned pattern, thickness); Example: setlinestyle(SOLID_LINE, 0, 1); 9. To fill color in an object: to fill color in objects we have set fill style in-built function. It has two parameters fill style pattern, color. Syntax: setfillstyle(fill style pattern, COLOR); Example: Setfillstyle(SOLID_FILL,RED);
10
Output
11
12
Output
13
14
Output
15
16
Output
17
18
Output
19
20
Output
21
22
} getch(); }
Output
23
24
Output
25
26
Output
27
Programs of 2D Transformations
Program to show the Translation of a line
#include<graphics.h> #include<iostream.h> #include<conio.h> #include<dos.h> #include<stdlib.h> void main() { int gd=DETECT,gm; int x,x1,y,y1,r,tx,ty; initgraph(&gd,&gm," "); cleardevice(); setcolor(7); cout<<"enter value x,y,r"; cin>>x>>y>>r; circle(x,y,r); cout<<"enter value tx,ty"; cin>>tx>>ty; x1=tx+x; y1=ty+y; setcolor(5); circle(x1,y1,r); getch();
28
Output
29
30
Output
31
32
cout<<"Enter value for x1,y1,r"; cin>>x1>>y1>>r; int xn1=x1+p; int yn1=y1+s; circle(xn1,yn1,r); cout<<"which reflection do u want"; cin>>n;
33
34
35
Output
36
37
pieslice(200,300,220,250,90); setcolor(8); pieslice(200,300,250,300,90); setcolor(9); pieslice(200,300,300,360,90); setcolor(10); outtextxy(150,150,"Food Items"); outtextxy(215,275,"MILK 30%"); outtextxy(175,275,"Egg"); outtextxy(120,275,"Curd"); outtextxy(120,315,"Chicken"); outtextxy(130,355,"Barfi"); getch(); closegraph(); }
38
39
Output
40
41
Output
42
43
44
Output
45
46
Output
47
48
49
50
51
52
while((x<=mx)||(y<=my)) { cleardevice(); setcolor(7); circle(x,y,30); line(x,y+30,x,y+100); line(x,y+100,x-50,y+200); line(x,y+100,x+50,y+200); line(x,y+50,x+50,y+50); line(x+50,y+50,x+75,y+25); line(x-50,y+200,x-75,y+175); line(x+50,y+200,x+75,y+175); circle(x-15,y-10,1); circle(x+15,y-10,1); line(x,y-5,x,y+5); line(x+75,y+25,x+75,y); circle(x+75,y-20,20); setfillstyle(1,rand()%15); floodfill(x+75,y-20,7); delay(700); arc(x,y+20,0,180,5); x=x+rand()%10; y=y-rand()%10; }
53
Output
54