Question: Practical lab: Computer Graphics Sheet 3: Chapter 3: 2D GRAPHICS ALGORITHMS Introduction to BGI Library Practice 1. Write a simple program that initialize new windows



Practical lab: Computer Graphics Sheet 3: Chapter 3: 2D GRAPHICS ALGORITHMS Introduction to BGI Library Practice 1. Write a simple program that initialize new windows for drawing (using BGI library). Code: include graphics. void main() ( inted.cn detect graph(d, aga); initgraph(&ed, prc/labs/bgi"); // Initialize lay new windows BGI. getch(); closegraph(); > Output: 1 Practical Lab: Sheet 3 Note: INITGRAPH Initializes the graphics system. Declaration Void far initgraph(int for graphdriver) Remarks .To start the graphic system, you must first call Initgraph. Initgraph initializes the graphic system by loading a graphics driver from disk (or validating a registered driver) then putting the system into graphics mode. Initgraph also resets all graphics settings (color palette, current position, viewport, etc) to their defaults then resets graph. CLOSE GRAPH Shuts down the graphie system. Decleration Void tar closegraph (void) Remarks Close graph deallocates all memory allocated by the graphic system. . It then restores the screen to the mode it was in before you called initgraph. Return value None Practice 2. Modify the above program (Practice 1) to draw a line. Output: Note: LINE LINERELLINETO Line draws a line between two specified pints. Onerel draws a line relative distance from current position (CP). Linto draws a line from the current position (CP) to (x,y). 2 Practical Lab: Sheet 3 Remarks .Line draws a line from (x1, yi) to (x2, y2) using the current colo line style and thickness. It does not update the current position (CP). Linerel draws a line from the CP to a point that is relati distance (dx, dy) from the CP, then advances the CP by (dx, dy). . Lineto draws a line from the CP to (x, y), then moves the CP (x,y). Return value None Practice 3. Modify the above program (Practice 1) to draw a rectangle. Output: Note: RECTANGLE Draws a rectangle in graphics mode. Decleration Void far rectangle (int left, int top, int right, int bottom) Remarks It draws a rectangle in the current line style, thickness a drawing color . (left, top) is the upper left corner of the rectangle, and (righ bottom) is its lower right corner. Return value - None. 3 Practical Lab: Sheet Practice 4. Modify the above program (Practice 1) to draw a circle. Output: Note: ARC, CIRCLE ar draws a circular arc. . Circle draws a circle Decleration void far are(int x; int y, int stangle, Int endangle, int radius); Void far circle(int x, int y int radius); Remarks .Are draws a circular are in the current drawing color Circle draws a circle in the current drawing color Practice 5. Modify the above program (Practice 1) to draw this graphics 4 Practical Lab Sheet 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
