C Language Program To Display Dialog Box


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

union REGS i,o;
char *dbox,*yes_up,*no_up,*yes_down,*no_down,*icon;

void DrawDialogBox(void);
void DialogBox(void);
int initmouse(void);
void showmouseptr(void);
void hidemouseptr(void);
void getmousepos(int *button,int *x,int *y);

void main(void)
{
                int gdriver=DETECT,gmode,errorcode;
                initgraph(&gdriver, &gmode, "..//bgi");
                errorcode=graphresult();
                if(errorcode!=grOk)
                {
                                printf("Graphics not initialized");
                                printf("Error Status : %s",grapherrormsg(errorcode));
                                getche();
                                exit(1);
                }
                if(!initmouse())
                {
                                printf("Mouse driver can't be loaded");
                                getche();
                                exit(1);
                }
                DrawDialogBox();
                showmouseptr();
                setbkcolor(BROWN);
                DialogBox();
}

void DrawDialogBox(void)    //    actual drawing of dialog box
{
                int area;
                int poly[10];
                struct textsettingstype textinfo;
                gettextsettings(&textinfo);
                settextstyle(0,HORIZ_DIR,1);
                setfillstyle(1,BLUE);
                bar(200,160,400,235);
                setcolor(7);
                outtextxy(205,163,"Message");           //title bar
                setfillstyle(1,7);
                bar(200,175,400,250);
                bar(388,162,398,172);
                setcolor(WHITE);
                line(388,162,398,162);
                line(388,162,388,172);
                setcolor(5);
                line(388,172,398,172);
                line(398,162,398,172);
                setcolor(7);
                setcolor(8);
                outtextxy(390,164,"X");                 //close button
                outtextxy(260,190,"  Exit ?");           //message
                setcolor(WHITE);
                line(200,160,400,160);
                line(200,160,200,250);
                setcolor(8);                  //outside normal look
                line(400,160,400,250);
                line(200,250,400,250);
                setfillstyle(1,BLUE);
                outtextxy(243,223,"Yes");         //button text
                outtextxy(337,223,"No");
                setcolor(LIGHTBLUE);
                setcolor(WHITE);
                line(230,215,280,215);
                line(230,215,230,238);
                line(320,215,370,215);
                line(320,215,320,238);

                setcolor(8);
                line(280,215,280,238);
                line(230,238,280,238);

                line(370,215,370,238);
                line(320,238,370,238);
                poly[0] = 100;
                poly[1] = 100;
                poly[2] = 90;
                poly[3] = 122;
                poly[4] = 110;
                poly[5] = 122;
                poly[6] = poly[0];
                poly[7] = poly[1];
                setcolor(YELLOW);
                setfillstyle(1,7);
                bar(89,99,111,123);
                setfillstyle(1,YELLOW);
                fillpoly(4, poly);
                setcolor(8);
                settextstyle(4,0,1);
                outtextxy(98,100,"!");
                setcolor(WHITE);
                area=imagesize(89,99,111,123);
                icon=malloc(area);
                getimage(89,99,111,123,icon);
                putimage(89,99,icon,XOR_PUT);
                putimage(210,180,icon,COPY_PUT);
                setfillstyle(1,BLUE);
                settextstyle(0,HORIZ_DIR,1);
                setcolor(WHITE);
                area=imagesize(198,158,402,252);
                dbox=malloc(area);
                getimage(198,158,402,252,dbox);
                putimage(198,158,dbox,XOR_PUT);
                putimage(198,158,dbox,XOR_PUT);

                area=imagesize(230,215,280,238);
                yes_up=malloc(area);
                getimage(230,215,280,238,yes_up);
                putimage(230,215,yes_up,XOR_PUT);
                putimage(230,215,yes_up,XOR_PUT);

                area=imagesize(320,215,370,238);
                no_up=malloc(area);
                getimage(320,215,370,238,no_up);
                putimage(320,215,no_up,XOR_PUT);
                putimage(320,215,no_up,XOR_PUT);

                setcolor(8);
                line(230,215,280,215);
                line(230,215,230,238);

                line(320,215,370,215);
                line(320,215,320,238);

                setcolor(WHITE);
                line(280,215,280,238);
                line(230,238,280,238);

                line(370,215,370,238);
                line(320,238,370,238);

                area=imagesize(230,215,280,238);
                yes_down=malloc(area);
                getimage(230,215,280,238,yes_down);
                putimage(230,215,yes_down,XOR_PUT);
                putimage(230,215,yes_down,XOR_PUT);

                area=imagesize(320,215,370,238);
                no_down=malloc(area);
                getimage(320,215,370,238,no_down);
                putimage(320,215,no_down,XOR_PUT);
                putimage(320,215,no_down,XOR_PUT);

                putimage(320,215,no_up,COPY_PUT);
                putimage(230,215,yes_up,COPY_PUT);
                settextstyle(textinfo.font,0,textinfo.charsize);
}

void DialogBox(void)       //Event Handler for dialog box
{
                int button,x,y,in1=0,in2=0;
                struct textsettingstype textinfo;
                cleardevice();
                putimage(198,158,dbox,XOR_PUT);
                showmouseptr();
                gettextsettings(&textinfo);
                settextstyle(0,HORIZ_DIR,1);
                while(1)
                {
                                getmousepos(&button,&x,&y);
                                if(x>=388&&x<=398&&y>=162&&y<=172)
                                {
                                                if((button&1)==1)
                                                {
                                                                while((button&1)==1)
                                                                                getmousepos(&button,&x,&y);
                                                                hidemouseptr();                    //close button click
                                                                cleardevice();
                                                                settextstyle(textinfo.font,0,textinfo.charsize);
                                                                hidemouseptr();
                                                                cleardevice();
                                                                showmouseptr();
                                                                DialogBox();
                                                                break;
                                                }
                                }
                                getmousepos(&button,&x,&y);
                                if(x>=230&&x<=280&&y>=215&&y<=238)
                                {
                                                if((button&1)==1)
                                                {
                                                                while((button&1)==1)
                                                                {
                                                                                getmousepos(&button,&x,&y);
                                                                                if(x>=230&&x<=280&&y>=215&&y<=238)
                                                                                {
                                                                                                if(in1==1) continue;
                                                                                                hidemouseptr();
                                                                                                putimage(230,215,yes_down,COPY_PUT);
                                                                                                showmouseptr();
                                                                                                in1=1;
                                                                                }                                    //yes button click
                                                                                else
                                                                                {
                                                                                                if(in1==0)
                                                                                                                continue;
                                                                                                hidemouseptr();
                                                                                                putimage(230,215,yes_up,COPY_PUT);
                                                                                                showmouseptr();
                                                                                                in1=0;
                                                                                }
                                                                }
                                                                if(x>=230&&x<=280&&y>=215&&y<=238)
                                                                {
                                                                                closegraph();
                                                                                restorecrtmode();
                                                                                exit(0);
                                                                }
                                                }
                                }
                                if(x>=320&&x<=370&&y>=215&&y<=238)
                                {
                                                if((button&1)==1)
                                                {
                                                                while((button&1)==1)
                                                                {
                                                                                getmousepos(&button,&x,&y);
                                                                                if(x>=320&&x<=370&&y>=215&&y<=238)
                                                                                {
                                                                                                if(in2==1) continue;
                                                                                                hidemouseptr();
                                                                                                putimage(320,215,no_down,COPY_PUT);
                                                                                                showmouseptr();
                                                                                                in2=1;
                                                                                }
                                                                                else                                 //no button click
                                                                                {
                                                                                                if(in2==0)
                                                                                                                continue;
                                                                                                hidemouseptr();
                                                                                                putimage(320,215,no_up,COPY_PUT);
                                                                                                showmouseptr();
                                                                                                in2=0;
                                                                                }
                                                                }
                                                                getmousepos(&button,&x,&y);
                                                                if(x>=320&&x<=370&&y>=215&&y<=238)
                                                                {
                                                                                hidemouseptr();
                                                                                cleardevice();
                                                                                settextstyle(textinfo.font,0,textinfo.charsize);
                                                                                hidemouseptr();
                                                                                cleardevice();
                                                                                showmouseptr();
                                                                                DialogBox();
                                                                }
                                                }
                                }
                }
}

//            Mouse Functions

int initmouse(void)
{
                i.x.ax=0;
                int86(0x33,&i,&o);
                return (o.x.ax);
}

void showmouseptr(void)
{
                i.x.ax=1;
                int86(0x33,&i,&o);
}

void hidemouseptr(void)
{
                i.x.ax=2;
                int86(0x33,&i,&o);
}

void getmousepos(int *button,int *x,int *y)
{
                i.x.ax=3;
                int86(0x33,&i,&o);
                *button=o.x.bx;
                *x=o.x.cx;
                *y=o.x.dx;
}


Contact:

Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704
Email: roshanphelonde@rediffmail.com
Share:

C Language Program To Display Circles


#include <graphics.h>           /* For graphics library functions */
#include <stdlib.h>             /* For exit() */
#include <stdio.h>
#include <conio.h>

int set_graph(void);            /* Initialize graphics */
void calc_coords(void);         /* Scale distances onscreen */
void draw_planets(void);        /* Draw and fill planet circles */

/* Draw one planet circle */
void draw_planet(float x_pos, float radius,
                 int color, int fill_style);
void get_key(void);         /* Display text on graphics screen, */
                            /* wait for key */

/* Global variables -- set by calc_coords() */
int max_x, max_y;           /* Maximum x- and y-coordinates */
int y_org;                  /* Y-coordinate for all drawings */
int au1;                    /* One astronomical unit in pixels
                               (inner planets) */
int au2;                    /* One astronomical unit in pixels
                               (outer planets) */
int erad;                   /* One earth radius in pixels */

int main()
{
   /* Exit if not EGA or VGA */
   /* Find out if they have what it takes */
   if (set_graph() != 1) {
      printf("This program requires EGA or VGA graphics\n");
      exit(0);
   }
   calc_coords();       /* Scale to graphics resolution in use */
   draw_planets();      /* Sun through Uranus (no room for others) */
   get_key();           /* Display message and wait for key press */
   closegraph();        /* Close graphics system */

   return 0;
}

int set_graph(void)
{
   int graphdriver = DETECT, graphmode, error_code;

   /* Initialize graphics system; must be EGA or VGA */
   initgraph(&graphdriver, &graphmode, "..\\bgi");
   error_code = graphresult();
   if (error_code != grOk)
      return(-1);               /* No graphics hardware found */
   if ((graphdriver != EGA) && (graphdriver != VGA))
   {
      closegraph();
      return 0;
   }
   return(1);                   /* Graphics OK, so return "true" */
}

void calc_coords(void)
{
   /* Set global variables for drawing */
   max_x = getmaxx();           /* Returns maximum x-coordinate */
   max_y = getmaxy();           /* Returns maximum y-coordinate */
   y_org = max_y / 2;           /* Set Y coord for all objects */
   erad = max_x  / 200;         /* One earth radius in pixels */
   au1 = erad * 20;             /* Scale for inner planets */
   au2 = erad * 10;             /* scale for outer planets */
}

void draw_planets()
{
   /* Each call specifies x-coordinate in au, radius, and color */
   /* arc of Sun */
   draw_planet(-90, 100, EGA_YELLOW, EMPTY_FILL);
   /* Mercury */
   draw_planet(0.4 * au1, 0.4 * erad, EGA_BROWN, LTBKSLASH_FILL);
   /* Venus */
   draw_planet(0.7 * au1, 1.0 * erad, EGA_WHITE, SOLID_FILL);
   /* Earth */
   draw_planet(1.0 * au1, 1.0 * erad, EGA_LIGHTBLUE, SOLID_FILL);
   /* Mars */
   draw_planet(1.5 * au1, 0.4 * erad, EGA_LIGHTRED, CLOSE_DOT_FILL);
   /* Jupiter */
   draw_planet(5.2 * au2, 11.2 * erad, EGA_WHITE, LINE_FILL);
   /* Saturn */
   draw_planet(9.5 * au2, 9.4 * erad, EGA_LIGHTGREEN, LINE_FILL);
   /* Uranus */
   draw_planet(19.2 * au2, 4.2 * erad, EGA_GREEN, LINE_FILL);
}

void draw_planet(float x_pos, float radius, int color, int fill_style)
{
   setcolor (color);                /* This becomes drawing color */
   circle(x_pos, y_org, radius);    /* Draw the circle */
   setfillstyle(fill_style, color); /* Set pattern to fill interior */
   floodfill(x_pos, y_org, color);  /* Fill the circle */
}

void get_key(void)
{
   outtextxy(50, max_y - 20, "Press any key to exit");
   getch();
}


Contact:

Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704
Email: roshanphelonde@rediffmail.com
Share:

C Language Program To Display Blinking Star


#include<conio.h>
#include<graphics.h>
#include<stdlib.h>
#include<dos.h>
void main()
 {
  int gdriver=DETECT,gmode;
  int i,x,y;
  initgraph(&gdriver,&gmode,"..//bgi");
  while(!kbhit())
   {
    x=random(640);
    y=random(480);
    setcolor(15);
    for(i=1;i<10;i++)
     {
      circle(x,y,i);
      delay(10);
     }
    setfillstyle(1,15);
    line(x+8,y-2,x+40,y);
    line(x+8,y+2,x+40,y);
    floodfill(x+11,y,15);
    line(x-8,y-2,x-40,y);
    line(x-8,y+2,x-40,y);
    floodfill(x-11,y,15);
    line(x-2,y+8,x,y+40);
    line(x+2,y+8,x,y+40);
    floodfill(x,y+11,15);
    line(x-2,y-8,x,y-40);
    line(x+2,y-8,x,y-40);
    floodfill(x,y-11,15);
    line(x+8,y-2,x+20,y-20);
    line(x+2,y-8,x+20,y-20);
    floodfill(x+15,y-15,15);
    line(x+8,y+2,x+20,y+20);
    line(x+2,y+8,x+20,y+20);
    floodfill(x+15,y+15,15);
    line(x-8,y+2,x-20,y+20);
    line(x-2,y+8,x-20,y+20);
    floodfill(x-15,y+15,15);
    line(x-8,y-2,x-20,y-20);
    line(x-2,y-8,x-20,y-20);
    floodfill(x-15,y-15,15);
    sound(4000);
    setcolor(0);
    for(i=40;i>=10;i--)
     {
      line(x+8,y-2,x+i,y);
      line(x+8,y+2,x+i,y);
     }
    for(i=40;i>=10;i--)
     {
      line(x-8,y-2,x-i,y);
      line(x-8,y+2,x-i,y);
     }
    for(i=40;i>=10;i--)
     {
      line(x-2,y+8,x,y+i);
      line(x+2,y+8,x,y+i);
     }
    for(i=40;i>=10;i--)
     {
      line(x-2,y-8,x,y-i);
      line(x+2,y-8,x,y-i);
     }
    for(i=20;i>=7;i--)
     {
      line(x+8,y-2,x+i,y-i);
      line(x+2,y-8,x+i,y-i);
     }
    for(i=20;i>=7;i--)
     {
      line(x+8,y+2,x+i,y+i);
      line(x+2,y+8,x+i,y+i);
     }
    for(i=20;i>=7;i--)
     {
      line(x-8,y+2,x-i,y+i);
      line(x-2,y+8,x-i,y+i);
     }
    for(i=20;i>=7;i--)
     {
      line(x-8,y-2,x-i,y-i);
      line(x-2,y-8,x-i,y-i);
     }
    for(i=9;i>0;i--)
     {
      circle(x,y,i);
      delay(10);
     }
    nosound();
   }
   cleardevice();
   setcolor(2);
   settextstyle(2,0,1);
   outtextxy(220,160," ");
   outtextxy(265,235," ");
   outtextxy(210,335," ");
   getch();getch();
 }



Contact:
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704
Email: roshanphelonde@rediffmail.com
Share:

C Language Program To Display Barchart


#include           <stdio.h>
#include           <stdlib.h>
#include           <float.h>
#include           <graphics.h>
#include           <math.h>
#include           <conio.h>
#define            MAX        50
#define            SIZE   5

void barchart(float p[]);

void main(void)
{
  int              i;
  int              scores[SIZE];
  float            percents[SIZE];

  for (i = 0; i < SIZE; i++)
    {
    printf("\nEnter score between 0 and %d:  ", MAX);
    scanf("%d", &scores[i]);
    }
  for (i = 0; i < SIZE; i++)
    percents[i] = ((float) scores[i]) / MAX;

  printf("\n\n\n\tSCORE\tPERCENT");
  for (i = 0; i < SIZE; i++)
    printf("\n%d. \t%d\t%3.0f", i + 1, scores[i], (percents[i] * 100));
  getch();
  barchart(percents);
}

void barchart(float p[])
{
  int   g_driver, g_mode;
  int   i, left, top, wide, bottom, deep;
  detectgraph(&g_driver, &g_mode);
  initgraph(&g_driver, &g_mode, "..\\bgi");
  wide = (int)((getmaxx()) / ((SIZE * 2 ) + 1));
  bottom = getmaxy() - 20;
  deep = (int) (wide / 4);
  left = wide;
  for (i = 0; i < SIZE; i++)
    {
    top = (bottom) - ((int)(p[i] * 300));
    setcolor(5);
    bar3d(left, top, (left + wide), bottom, deep, 1);
    left += (wide * 2);
    }
  getch();
  closegraph();
  return;
}

Sample Input :
Enter score between 0 and 50:  5
Enter score between 0 and 50:  6
Enter score between 0 and 50:  45
Enter score between 0 and 50:  3
Enter score between 0 and 50:  1

        SCORE   PERCENT
1.      5        10
2.      6        12
3.      45       90
4.      3         6
5.      1         2


Contact:
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704
Email: roshanphelonde@rediffmail.com
Share:

C Language Progarm for Display Analog Clock


# include <graphics.h>
# include <dos.h>
# include <stdio.h>
# include <conio.h>
# include <math.h>
# include <process.h>
void frame();
void star_in(int, int, int, int, int, float, float);
void line_at_angle(int, float, int);
void beep(int, int);
void clear (int, int, int, int, int);

void main()
{
  struct time t;
  int key,k=0,i;
  int midx,midy;
  int t_sec,t_min;
    int x=520,y=460;
  float hour;
    char tim[5];
  float ang_sec=t.ti_sec*6;
    float ang_min=(t.ti_min*6)+(ang_sec/60);
    float ang_hour=(hour*30)+(ang_min/12);
    int gdriver=DETECT,gmode,errorcode;
  initgraph(&gdriver,&gmode,"..//bgi");
  errorcode=graphresult();
  if(errorcode!=grOk)
  {
    printf("Graphics error  %s",grapherrormsg(errorcode));
    printf("press any key to halt.");
    exit(1);
  }
 
  gettime(&t);
 
  midx=getmaxx()/2;
  midy=getmaxy()/2;

  frame();

  while(1)
  {
    if(kbhit())
    {
      key=getch();
      if(key==27)
      break;
    }
    gettime(&t);

    if(t.ti_hour>=12)
    hour=t.ti_hour-12;



    setcolor(4);
    setfillstyle(1,9);
    line_at_angle(150,ang_min,2);  //min
    setcolor(12);
    setfillstyle(1,4);
    line_at_angle(130,ang_hour,3);  //hour
    setcolor(14);
    line_at_angle(170,ang_sec,1);  //sec
    line_at_angle(20,180+ang_sec,1);  //sec

    setfillstyle(1,4);
    setcolor(13);
                  /*fillellipse(midx,midy,2,2);*/
    star_in(midx, midy+1, 6, 2, 4, 0, 0);

    //struct time t;

    gettime(&t);
    if(t.ti_hour>12)
    {
      outtextxy(x+80,y,"PM");
      sprintf(tim,"%d",t.ti_hour-12);
    }
    else
    {
      outtextxy(x+80,y,"AM");
      sprintf(tim,"%d",t.ti_hour);
    }
    outtextxy(x,y,tim);
    outtextxy(x+16,y,":");
    outtextxy(x+42,y,":");
    sprintf(tim,"%d",t.ti_min);
    outtextxy(x+26,y,tim);
    sprintf(tim,"%d",t.ti_sec);
    outtextxy(x+50,y,tim);

    k++;
    if(k==10)
    {
      k=0;
      beep(100,50);
    }
    else
    delay(100);
    t_sec = t.ti_sec;
    t_min = t.ti_min;
    clear(x+50,y,x+70,y+8,0);
    if(t_sec >= 59)
    clear(x+26,y,x+46,y+8,0);
    if(t_min >= 59)
    clear(x,y,x+20,y+8,0);

    setcolor(0);
    setfillstyle(1,0);
    line_at_angle(130,ang_hour-6,1);
    line_at_angle(150,ang_min-4,1);
    line_at_angle(170,ang_sec,1);
    line_at_angle(20,180+ang_sec,1);
    ang_sec++;
  }

  closegraph();
}
void frame()
{
  int midx,midy,i;
  float angle=0;
  float x,y;
  midx=getmaxx()/2;
  midy=getmaxy()/2;

  setlinestyle(1,1,3);
  setcolor(2);
  circle(midx,midy,223);
  setcolor(15);
  circle(midx,midy,220);
  setcolor(12);
  circle(midx,midy,217);
  setlinestyle(1,1,3);
  setfillstyle(1,2);
  setcolor(4);
  for(i=0;i<=60;i++)
  {
    x=cos((angle/180)*M_PI)*190;
    y=sin((angle/180)*M_PI)*190;
    if((int)(angle)%30!=0)
    circle(midx+x,midy+y,2);
    angle+=6;
  }
  angle=0;
  setfillstyle(1,4);
  setlinestyle(0,1,2);
  for(i=0;i<12;i++)
  {
    setcolor(13);
    x=cos((angle/180)*M_PI)*190;
    y=sin((angle/180)*M_PI)*190;
    if(i%3==0)
    {
//      fillellipse(midx+x,midy+y,6,6);
      setcolor(10);
      star_in(midx+x, midy+y, 12, 6, 5, 18, 0);
      setcolor(14);
      star_in(midx+x, midy+y, 6, 3, 5, 18, 0);
    }
    else
 //   fillellipse(midx+x,midy+y,4,4);
    star_in(midx+x, midy+y, 8, 3, 5, 18, 0);
    angle+=30;
  }
}

void line_at_angle(int radius, float angle, int flag)
{
  float x,y,x1,y1,x2,y2,x3,y3;
  int midx,midy;
  int poly1[10];
  angle-=90;
  midx=getmaxx()/2;
  midy=getmaxy()/2;
  x=cos((angle/180)*M_PI)*radius;
y=sin((angle/180)*M_PI)*radius;
setlinestyle(0,1,3);
  if(flag==1)
  line(midx,midy,midx+x,midy+y);
  if(flag==2)
  {
    setlinestyle(0,1,1);
    x2=cos(((angle+3)/180)*M_PI)*(radius-25);
    y2=sin(((angle+3)/180)*M_PI)*(radius-25);
    x3=cos(((angle-3)/180)*M_PI)*(radius-25);
    y3=sin(((angle-3)/180)*M_PI)*(radius-25);
    //poly1[10]={midx,midy,midx+x2,midy+y2,midx+x,midy+y,midx+x3,midy+y3,midx,midy};
    fillpoly(5,poly1);
    setcolor(0);
    x2=cos(((angle)/180)*M_PI)*(radius+1);
    y2=sin(((angle)/180)*M_PI)*(radius+1);
    x3=cos(((angle-4)/180)*M_PI)*(radius-25);
    y3=sin(((angle-4)/180)*M_PI)*(radius-25);
    line(midx+x2,midy+y2,midx+x3,midy+y3);
    line(midx+x,midy+y,midx+x3,midy+y3);
  }
  else if(flag==3)
  {
    setlinestyle(0,1,1);
    x2=cos(((angle+5)/180)*M_PI)*(radius-30);
    y2=sin(((angle+5)/180)*M_PI)*(radius-30);
    x3=cos(((angle-5)/180)*M_PI)*(radius-30);
    y3=sin(((angle-5)/180)*M_PI)*(radius-30);
//poly1={midx,midy,midx+x2,midy+y2,midx+x,midy+y,midx+x3,midy+y3,midx,midy};
    fillpoly(5,poly1);
    setcolor(0);
    x2=cos(((angle)/180)*M_PI)*(radius+1);
    y2=sin(((angle)/180)*M_PI)*(radius+1);
    x3=cos(((angle-6)/180)*M_PI)*(radius-30);
    y3=sin(((angle-6)/180)*M_PI)*(radius-30);
    line(midx+x2,midy+y2,midx+x3,midy+y3);
    line(midx+x,midy+y,midx+x3,midy+y3);
  }
}
void beep(int fre,int wait)
{
  sound(fre);
  delay(wait);
  nosound();
}
  void star_in(int x, int y, int r1, int r2, int points, float
angle_intial1, float offset)
  {
    float angle, theta;
    int number = 0;
    float xi1, yi1, xf1, yf1, xc1, yc1;
    float xi2, yi2, xf2, yf2, xc2, yc2;
    float angle_intial2;
    float xt,yt;

    theta = 360 / points;
    angle_intial2 = angle_intial1 + (theta / 2) + offset;
    angle_intial1 = (angle_intial1 * M_PI) / 180;
    angle_intial2 = (angle_intial2 * M_PI) / 180;

    angle = theta;

    xc1 = x + (r1 * cos(angle_intial1)),
    yc1 = y - (r1 * sin(angle_intial1));
    xc2 = x + (r2 * cos(angle_intial2)),
    yc2 = y - (r2 * sin(angle_intial2));

    xi1 = xc1,
    yi1 = yc1;
    xi2 = xc2,
    yi2 = yc2;

    xt = xc1;
    yt = yc1;

    while(number <= points + 1)
    {
      angle = (angle * M_PI) / 180;

      xc1 = xc1 - x;
      yc1 = yc1 - y;
      xc2 = xc2 - x;
      yc2 = yc2 - y;

      xf1 = ( xc1 * cos(angle) ) - ( yc1 * sin( angle ) );
      yf1 = ( xc1 * sin(angle) ) + ( yc1 * cos( angle ) );
      xf2 = ( xc2 * cos(angle) ) - ( yc2 * sin( angle ) );
      yf2 = ( xc2 * sin(angle) ) + ( yc2 * cos( angle ) );

      xc1 = xc1 + x;
      yc1 = yc1 + y;
      xc2 = xc2 + x;
      yc2 = yc2 + y;

      xf1 = xf1 + x;
      yf1 = yf1 + y;
      xf2 = xf2 + x;
      yf2 = yf2 + y;

      if(number != points + 1)
      line(xi1, yi1, xi2, yi2);
      line(xt, yt, xi2, yi2);

      xt = xi1;
      yt = yi1;

      xi1 = xf1,
      yi1 = yf1;
      xi2 = xf2,
      yi2 = yf2;

      number++;
      angle = theta * number;
    }
  }

void clear(int x1, int y1, int x2, int y2, int col)
{
    int x,y;
    for(x=x1;x<=x2;x++)
    for(y=y1;y<=y2;y++)
    putpixel(x,y,col);
}


Contact:
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704
Email: roshanphelonde@rediffmail.com
Share:

Total Pageviews

CONTACT US

Prof. Roshan P. Helonde
Mobile: +917276355704
WhatsApp: +917276355704
Email: roshanphelonde@rediffmail.com

Enter Project Title

Popular Projects

All Archive

Contact Form

Name

Email *

Message *