- 1. COMPUTER GRAPHICS - DANCING DOLL
- 2. BASICS: Computer graphics is an art of drawing pictures on computer screens with the help of programming and algorithms. It involves computations, creation, and manipulation of data. In other words, we can say that computer graphics is a rendering tool for the generation and manipulation of images. Application of Computer Graphics 1.Computer graphics user interfaces (GUIs). 2.Business presentation graphics 3.Cartography Weather Maps 4.Satellite Imaging Photo Enhancement 5.Medical Imaging 6.Engineering drawings 7.Typography 8.Architecture Art 9.Entertainment 10.Simulation and modeling
- 3. GRAPHICS.H Used to draw different shapes, display text in different fonts, change colors and many more. Using functions of graphics.h in Turbo C compiler you can make graphics programs, animations, projects, and games. You can draw circles, lines, rectangles, bars and many other geometrical figures. You can change their colors using the available functions and fill them. Following is a list of functions of graphics.h header file. Every function is discussed with the arguments it needs, its description GRAPHICS.H FUNCTIONS arc bar bar3d circle cleardevice closegraph drawpoly ellipse fillellipse fillpoly floodfill getarccords getbkcolor getcolor getdrivername getimage getmaxcolor getmaxx getmaxy getpixel getx gety graphdefaults grapherrormsg imagesize line lineto linerel moveto moverel outtext outtextxy pieslice putimage putpixel rectangle sector setbkcolor setcolor setfillstyle setlinestyle settextstyle setviewport textheight textwidth
- 4. BASICS: LINE GENERATION ALGORITHM In any 2-Dimensional plane if we connect two points (x0, y0) and (x1, y1), we get a line segment. But in the case of computer graphics we can not directly join any two coordinate points, for that we should CALCULATE INTERMEDIATE POINT’S COORDINATE and put a pixel for each intermediate point, of the desired color with help of functions like putpixel(x, y, K) in C, where (x,y) is our co-ordinate and K denotes some color DDAALGORITHM BRESENHAM’S LINE GENERATION MID-POINT ALGORITHM
- 5. DDA- LINE GENERATION ALGORITHM Consider one point of the line as (X0,Y0) and the second point of the line as (X1,Y1). // calculate dx , dy dx = X1 - X0; dy = Y1 - Y0; // Depending upon absolute value of dx & dy // choose number of steps to put pixel as // steps = abs(dx) > abs(dy) ? abs(dx) : abs(dy) steps = abs(dx) > abs(dy) ? abs(dx) : abs(dy); // calculate increment in x & y for each steps Xinc = dx / (float) steps; Yinc = dy / (float) steps; // Put pixel for each step X = X0; Y = Y0; for (int i = 0; i <= steps; i++) { putpixel (X,Y,WHITE); X += Xinc; Y += Yinc; }
- 6. BASICS: CIRCLE GENERATION ALGORITHM Drawing a circle on the screen is a little complex than drawing a line. There are two popular algorithms for generating a circle: Bresenham’s Algorithm and Midpoint Circle Algorithm. These algorithms are based on the idea of determining the subsequent points required to draw the circle. Bresenham’s Algorithm: Step 1 − Get the coordinates of the center of the circle and radius, and store them in x, y, and R respectively. Set P=0 and Q=R. Step 2 − Set decision parameter D = 3 – 2R. Step 3 − Repeat through step-8 while P ≤ Q. Step 4 − Call Draw Circle X,Y,P,QX,Y,P,Q. Step 5 − Increment the value of P. Step 6 − If D < 0 then D = D + 4P + 6. Step 7 − Else Set R = R - 1, D = D + 4P−QP−Q + 10. Step 8 − Call Draw Circle X,Y,P,Q. putpixel (X + P, Y + Q) putpixel (X - P, Y + Q) putpixel (X + P, Y - Q) putpixel (X - P, Y - Q) putpixel (X + Q, Y + P) putpixel (X - Q, Y + P) putpixel (X + Q, Y - P) putpixel (X - Q, Y - P)
- 7. BASICS: POLYGON FILLING Polygon is an ordered list of vertices as shown in the following figure. For filling polygons with particular colors, you need to determine the pixels falling on the border of the polygon and those which fall inside the polygon. Scan Line Algorithm Flood Fill Algorithm Boundary Fill Algorithm 4-Connected Polygon 8-Connected Polygon Inside-outside Test : 1. Odd-Even Rule 2.Nonzero winding number rule
- 8. COMPUTER ANIMATION The basic idea behind animation is to play back the recorded images at the rates fast enough to fool the human eye into interpreting them as continuous motion. Animation can make a series of dead images come alive. Animation can be used in many areas like entertainment, computer aided-design, scientific visualization, training, education, e-commerce, and computer art. Traditional Animation (frame by frame) : Key Framing A keyframe is a frame where we define changes in animation. Every frame is a keyframe when we create frame by frame animation. When someone creates a 3D animation on a computer, they usually don’t specify the exact position of any given object on every single frame. They create keyframes. Keyframes are important frames during which an object changes its size, direction, shape or other properties. The computer then figures out all the in-between frames and saves an extreme amount of time for the animator. The following illustrations depict the frames drawn by user and the frames generated by computer.
- 9. DANCING DOLL: Visualization Initial position
- 10. DANCING DOLL: CODE & OUTPUT
- 11. DANCING DOLL: DANCING DOLL