This blog is under construction

Thursday 5 September 2013

WIFI antenna animation using C graphics

Animate WIFI antenna using C graphics


  #include <stdio.h>
  #include <conio.h>
  #include <graphics.h>
  #include <dos.h>

  int main() {
        /* request auto detection */
        int gdriver = DETECT, gmode, err;
        int midx, y, radius = 5;
        int k = 0, stangle, endangle;

        /* initialize graphic mode */
        initgraph(&gdriver, &gmode, "C:/TURBOC3/BGI");
        err = graphresult();

        if (err != grOk) {
                /* error occurred */
                printf("Graphics Error: %s\n",
                grapherrormsg(err));
                getch();
                return 0;
        }

        /* mid position in x-axis */
        midx = getmaxx() / 2;
        /* calculating the position of y */
        y = (3 * getmaxy()) / 4;

        /* start and end angles of signals */
        stangle = 120;
        endangle = 200;

        while (!kbhit()) {
                k = 0, radius = 5;

                /* clears graphic screen */
                cleardevice();

                /* construct antenna using lines */
                line(midx - 50, getmaxy(), midx, y);
                line(midx + 50, getmaxy(), midx, y);
                line(midx - 25, getmaxy(), midx, y);
                line(midx + 25, getmaxy(), midx, y);
                line(midx - 45, getmaxy() - 10, midx + 45, getmaxy() - 10);
                line(midx - 30, getmaxy() - 50, midx + 30, getmaxy() - 50);
                line(midx - 16, getmaxy() - 80, midx + 16, getmaxy() - 80);

                /* signals from the antenna */
                while (k < 18) {
                        /* signal at the left side */
                        arc(midx, y, stangle, endangle, radius);
                        /* signal at the right side */
                        arc(midx, y, 0, 60, radius);
                        arc(midx, y, 340, 360, radius);
                        radius = radius + 15;
                        delay(50);
                        k++;
                }
        }

        getch();

        /* deallocate memory allocated for graphic screen */
        closegraph();

        return 0;
  }




Output:(Animate WIFI antenna using C graphics)


1 comment: