Introduction to Graphics

By Bipin Tiwari

 Important Questions

Graphics Characteristics

  1. Pixels

A pixel is a short from of picture Element and it represent a single point in a graphic image.

  2. Resolution

The number of pixels used on the screen is called resolution.

   3. Colors

Some graphics modes support more colors than others ranging from 2 to millions colors.  A particular mode may        support only two colors at a time while other may support 256 colors. These groups of colors are known as color          palettes,

   4. Video Adapters

Video adapters are drivers for display. Each video adapters handles graphics in different way. Some examples of video adapters are CGA, VGA and EGA. Each video adapter supports different resolutions and colors.

Example

Write a program to draw a circle with center point at (200, 200) and radius 50 pixels.

 

#include<graphics.h>
 int main()
   {
     int gd=DETECT,gm;
     char txt [20];
   intitgraph(&gd, &gm, "c:");
   circle(200,200,50);
     getch();
    closegraph();
     return 0:
  }

Output

../_images/drawing_circle.png

Example

Write a program to draw a hexagon.

#include<graphics.h>
 int main ()
{
   int gdriver = DETECT, gmode;
 
    int poly [] = {10,75,50,25,100,25,140,75,100125,50,125,10,75};
    intgraph(&gdriver, &gmode, "c:\\tc\\bgi");
 drawpoly(7,poly);
  fillpoly(7, poly);
  closegraph ();
 return 0;
}

Output

Download Hexagon Geometrical Shape Outline for free | Hexagon, Hexagon quilt pattern, Draw a hexagon

 

 

Important Questions
Comments
Subscribe
Notify of
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments