Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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.h" void main() int gd, gm; detectgra 1,&p); initgraph(&gd,&gm,"c:/labs/bgi"); // Initialize lay new windows BGI. getch(); closegraph(); } Output: Wirelor cu 1 Practical Lab: Sheet 3 Note: INITGRAPH . Initializes the graphics system. Declaration Void far initgraph(int far *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 graphic system. Decleration . Void far 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). . Linrto draws a line from the current position (CP) to(x,y). 2 Practical Lab: Sheet 3 Decleration Void far lineto (int x, int y) Remarks Line draws a line from (xl, yl) to (x2, y2) using the current color, line style and thickness. It does not update the current position (CP). Linerel draws a line from the CP to a point that is relative 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 to (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 and drawing color. . (left, top) is the upper left corner of the rectangle, and (right, bottom) is its lower right corner. Return value . None. 3 Practical Lab: Sheet 3 Practice 4. Modify the above program (Practice 1) to draw a circle. Output: Note: ARC, CIRCLE .arc draws a circular arc. Circle draws a circle Decleration Void far arc(int x, int y, int stangle, int endangle, int radius); Void far circle(int x, int y, int radius); Remarks Arc draws a circular arc 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 graphic: CS Jamount Windows for drawing 4 Practical Lab: Sheet 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions