Pages

Saturday, 17 February 2018

OSI Layer C Graphics

OSI Layer C Graphics

Amazing OSI layer animation using c language graphics programming 




/*==============================
     Girfa Student Help
     Program : OSI Layer Using C Graphics
     More Program : http://girfahelp.blogspot.in/p/graphics-c-language.html
     Coder : Mayank Khare,BCA
================================*/
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#define x 1000
int main(void)
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int xmax, ymax,i;

   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "");

   /* read result of initialization */
   errorcode = graphresult();

   /* an error occurred */
   if (errorcode != grOk)
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1);
   }
   outtextxy(270,30,"OSI 7 Layer ");

 for(i=0;i<300;i+=299)
 {

   /*1  draw a diagonal line */
   line(100+i,100,100+i,120);
   line(100+i,100,200+i,100);
   line(100+i,120,203+i,120);
   line(203+i,120,200+i,100);
   line(100+i,100,125+i,50);
   line(125+i,50,225+i,50);
   line(225+i,50,200+i,100);
   line(203+i,120,225+i,75);
   line(225+i,75,225+i,50);
   line(213+i,100,225+i,100);
  // floodfill(140, 55, 5);
  outtextxy(115,75, "TRANSMIT");
  outtextxy(120, 85, "DATA");
  if(i>0)
  {
      outtextxy(115+i,75, "RECEIVE");
      outtextxy(120+i, 85, "DATA");
  }
   outtextxy(110+i, 105, "APPLICATION");
   delay(x);
     //2 ***********/

   line(100+i,150,100+i,170);
   line(100+i,150,200+i,150);
   line(100+i,170,203+i,170);
   line(200+i,150,203+i,170);
   line(100+i,150,125+i,120);
   line(200+i,150,225+i,100);
   line(203+i,170,225+i,130);
   line(225+i,100,225+i,130);
   line(213+i,150,225+i,150);
   outtextxy(105+i, 155, "PRESENTATION");
   delay(x);
   //3***********/
   line(100+i,200,100+i,220);
   line(100+i,200,200+i,200);
   line(100+i,220,203+i,220);
   line(200+i,200,203+i,220);
   line(100+i,200,125+i,170);
   line(200+i,200,225+i,150);
   line(203+i,220,225+i,175);
   line(225+i,175,225+i,150);
   line(212+i,200,225+i,200);
   outtextxy(110+i, 205, "SESSION");
   delay(x);
   //4************/
   line(100+i,250,100+i,270);
   line(100+i,250,200+i,250);
   line(100+i,270,203+i,270);
   line(200+i,250,203+i,270);
   line(100+i,250,125+i,220);
   line(200+i,250,225+i,200);
   line(203+i,270,225+i,225);
   line(225+i,200,225+i,225);
   line(212+i,250,225+i,250);
   outtextxy(110+i, 255, "TRANSPORT");
   //5*********/
   delay(x);
   line(100+i,300,100+i,320);
   line(100+i,300,200+i,300);
   line(100+i,320,203+i,320);
   line(200+i,300,203+i,320);
   line(100+i,300,125+i,270);
   line(200+i,300,225+i,250);
   line(203+i,320,225+i,275);
   line(225+i,250,225+i,275);
   line(213+i,300,225+i,300);
   outtextxy(110+i, 305, "NETWORK");
   delay(x);
   //6**********/
    line(100+i,350,100+i,370);
    line(100+i,350,200+i,350);
    line(100+i,370,203+i,370);
    line(200+i,350,203+i,370);
    line(100+i,350,125+i,320);
    line(200+i,350,225+i,300);
    line(203+i,370,225+i,325);
    line(225+i,300,225+i,325);
    line(213+i,350,225+i,350);
    outtextxy(110+i, 355, "DATA LINK");
    //7********/
    delay(x);
     line(100+i,400,100+i,420);
     line(100+i,400,200+i,400);
     line(100+i,420,203+i,420);
     line(200+i,400,203+i,420);
     line(100+i,400,125+i,370);
     line(200+i,400,225+i,350);
     line(203+i,420,225+i,380);
     line(225+i,350,225+i,380);
     outtextxy(110+i, 405, "PHYSICAL");
     delay(x);
     }

   /* clean up */
   getch();
   closegraph();
   return 0;
}

No comments:

Post a Comment