⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clock&calendar.c

📁 BBS上淘来的一大堆C源代码
💻 C
字号:
void choose(int x,int y,int k)
{
   if(k==1)
         {
          setfillstyle(SOLID_FILL,10);
      floodfill(x,y-90,6);
      floodfill(x-50,y-90,6);
      floodfill(137,220,6);
      setfillstyle(SOLID_FILL,11);
          floodfill(75,220,6);
          }
         if(k==2)
      {
       setfillstyle(SOLID_FILL,10);
      floodfill(75,220,6);
      setfillstyle(SOLID_FILL,11);
      floodfill(137,220,6);
      }
      if(k==3)
      {printtime(x,y,6);
       setfillstyle(SOLID_FILL,10);
      floodfill(137,220,6);
      floodfill(75,220,6);
      setfillstyle(SOLID_FILL,11);
      floodfill(x-50,y-90,6);
      }
      if(k==4)
      {
       setfillstyle(SOLID_FILL,10);
      floodfill(137,220,6);
      setfillstyle(SOLID_FILL,10);
      floodfill(x-50,y-90,6);
      floodfill(75,220,6);
      setfillstyle(SOLID_FILL,11);
       floodfill(x,y-90,6);
      }
}
void mousepicture()
{
     int i,j,k;
     long hidenum[16]={
       0x3fff,0x1fff,0x0fff,0x07ff,
       0x03ff,0x01ff,0x00ff,0x007f,
       0x003f,0x00ff,0x01ff,0x10ff,
       0x30ff,0xf87f,0xf87f,0xfc3f
                        } ; /*隐码点值*/
   long burynum[16]={
       0x0000,0x7c00,0x6000,0x7000,
       0x7800,0x7c00,0x7e00,0x7f00,
       0x7f80,0x7e00,0x7c00,0x4600,
       0x0600,0x0300,0x0300,0x0180
                         };/*掩码点值*/
   for(i=0;i<16;i++)
   {
     for(j=15;j>1;j--)
     {
       hidedraw[i][j]=hidenum[i]%2;
       hidenum[i]=hidenum[i]/2;
       burydraw[i][j]=burynum[i]%2;
       burynum[i]=burynum[i]/2;
     }
   }
}
void mouseshow(int x,int y)
{
  int i,j;
  for(i=0;i<16;i++)
  {
    for(j=0;j<16;j++)
    {
      pixelsave[i][j]=getpixel(x+j,y+i);
      if(hidedraw[i][j]==0&&burydraw[i][j]==1)/*显示鼠标0&1*/
      putpixel(x+j,y+i,15);
    }
  }
}
void mousehide()
{
  int i,j;
  for(i=0;i<16;i++)
   {
     for(j=0;j<16;j++)
     {
      if(hidedraw[i][j]==1&&burydraw[i][j]==0)
      putpixel(mousex+j,mousey+i,BLACK);
      putpixel(mousex+j,mousey+i,pixelsave[i][j]);/*隐藏鼠标1&0*/
     }
   }
}
void mousesetx(int lx,int rx)/*设置鼠标横坐标取值范围*/
{
  _CX=lx;
  _DX=rx;
  _AX=0x07;
  geninterrupt(0x33);
}
int message()/*取鼠标按键信息*/
{
  int x;
  _AX=0x05;
  geninterrupt(0x33);
  if(leftpress())
  x=_BX;
  return x;
}
void mousesety(int uy,int dy)/*设置鼠标纵坐标取值范围*/
{
  _CX=uy;
  _DX=dy;
  _AX=0x08;
  geninterrupt(0x33);
}
void mousesetxy(int x,int y)/*设置鼠标初始位置*/
{
  _CX=x;
  _DX=y;
  _AX=0x04;
  geninterrupt(0x33);
}
void mousegetxy()/*取鼠标的横纵坐标*/
{
  _AX=0x03;
  geninterrupt(0x33);
  mousex=_CX;
  mousey=_DX;
}
int leftpress()/*按下左键*/
{
_AX=0x03;
geninterrupt(0x33);
return(_BX&1);
}
int rightpress()/*按下右键*/
{
  _AX=0x03;
  geninterrupt(0x33);
  return(_BX&2);

}
void mousemove()/*鼠标移动设置*/
{
  int i,j,press=0,move,x,y,x1,y1,second;
  char *rday,*rmonth;
  x=mousex;
  y=mousey;
  move=0;/*有无移动标致*/
  if(mousex==x&&mousey==y&&press==0&&move==0)
  {
   if(leftpress())
   press=1;
   else if(rightpress())
   press=2;
   mousegetxy();
   if(mousex!=x||mousey!=y)
   {
   setcolor(BLACK);
      /*??????????????????*/                    
   if((x>=35&&x<=295&&y>=256&&y<=365))/*控制鼠标在哪一个范围内擦除*/
   {
    if(x<=160&&y<=372)
    {
       drawmat(nong,12,x+62,y+10,BLACK);
       drawmat(li,12,x+62,y+30,BLACK);

       rectangle(x+10,y+10,x+60,y+40);
       setfillstyle(SOLID_FILL,BLACK);
       bar(x+11,y+11,x+59,y+39);
     }
    else if(x>160&&y<=372)
    {
       drawmat(nong,12,x-65,y+10,BLACK);
       drawmat(li,12,x-65,y+30,BLACK);

       rectangle(x-50,y+10,x,y+40);
       setfillstyle(SOLID_FILL,BLACK);
       bar(x-49,y+11,x-1,y+39);
     }
    }
   move=1;
   }
  }
  if(move)/*若有移动*/
  {

    for(i=0;i<16;i++)
   {
     for(j=0;j<16;j++)
     {
        if((x>=40&&x<=284&&y>=256&&y<=392))
       putpixel(x+j,y+i,BLACK);
       else
      putpixel(x+j,y+i,pixelsave[i][j]);
     }
   }
   mouseshow(mousex,mousey);
   data();
  }
}
void sound1()
{
  sound(30);
  delay(300);
  nosound();
}
 
void clock(int x,int y)
{
   int hour=0,minute=0,second=0;
   int x1,y1,xs,ys,x2,y2,xm,ym,xh,yh,x3,y3,r1=54,r2=54,i,j,col;
   int key,s,k=1,count1=0;    char name[40]="Design by xiaoxiong    71.8.5002";
   char *s1=0,*rday,*rmonth;
   mousesetx(0,getmaxx());
   mousesety(0,getmaxy());
   mousesetxy(160,300);
   mousepicture();
   getdate(&d);
   data();
   aaa(x,y);
      do
    {
      setcolor(2);
      circle(x,y,r1);
      setfillstyle(SOLID_FILL,BLACK);
      floodfill(x,y,2);
      cou=0;
      printtime(x,y,15);

printdata(15);
            for(i=0;i<=40;i++)/*绘制同心数字*/
      {
         setcolor(5);
         sprintf(s1,"%c",name[i]);
         outtextxy(-(r2-10)*cos(i*pi/18)+x-5,(r2-10)*sin(i*pi/18)+y-5,s1);
         setcolor(3);
         outtextxy(-(r2-9)*cos(i*pi/18)+x-5,(r2-9)*sin(i*pi/18)+y-5,s1);
      }
      setwritemode(XOR_PUT);
      xs=x+sin(second*pi/30)*r1;
      ys=y-cos(second*pi/30)*r1;
      xm=x+sin(minute*pi/30)*(r1-6);
      ym=y-cos(minute*pi/30)*(r1-6);
      xh=x+sin((hour*60+minute)*pi/360)*(r1-15);
      yh=y-cos((hour*60+minute)*pi/360)*(r1-15);
      gettime(&t);
      minute=t.ti_min;
      x2=x+sin(minute*pi/30)*(r1-6);
      y2=y-cos(minute*pi/30)*(r1-6);
      setcolor(BLACK);
      line(x,y,xm,ym);
      setcolor(WHITE);
      line(x,y,x2,y2);
      hour=t.ti_hour;
      x3=x+sin((hour*60+minute)*pi/360)*(r1-15);
      y3=y-cos((hour*60+minute)*pi/360)*(r1-15);
      setcolor(BLACK);
      line(x,y,xh,yh);
      setcolor(6);
      line(x,y,x3,y3);
      second=t.ti_sec;
      x1=x+sin(second*pi/30)*r1;
      y1=y-cos(second*pi/30)*r1;
      setcolor(BLACK);
      line(x,y,xs,ys);
      setcolor(10);
      line(x,y,x1,y1);
      setwritemode(COPY_PUT);
      printtime(x,y,6);
      printdata(6);
      choose(x,y,k);
      col=1;
      graph4();
     graph5();

      for(i=0;i<16;i++)
       {
       for(j=0;j<16;j++)
          {
           mouseplsave[i][j]=getpixel(mousex+j,mousey+i);
           if(mouseplsave[i][j]==9)
           {
           setcolor(col++);
           outtextxy(10,10,"ok");  /*??????????????????
           setcolor(3);
           circle(mousex+16,mousey+32,3);
           setfillstyle(SOLID_FILL,col++);
           floodfill(mousex+16,mousey+32,3);*/
           }
          }
        }
   while(t.ti_sec==second&&t.ti_hour==hour&&t.ti_min==minute)/*让秒针停止一秒*/
   {
     gettime(&t);

     for(i=0;i<6;i++)
     {
         for(j=0;j<6;j++)
         {
           mouseplsave[i][j]=getpixel(mousex+i,mousey+j);/*用鼠标取得日期颜色*/
           if(mouseplsave[i][j]==9)
           {
        setcolor(11);/* col>=14?col=1:col++*/
        if(mousex>=35&&mousex<=294&&mousey>=256&&mousey<=365)
   {
           if(mousex<=160&&y<=352)
           {
           drawmat(nong,12,mousex+62,mousey+10,col++);
           drawmat(li,12,mousex+62,mousey+30,col);
           rectangle(mousex+10,mousey+10,mousex+60,mousey+40);
           rectangle(mousex+11,mousey+11,mousex+59,mousey+39);
           setfillstyle(SOLID_FILL,13);
           floodfill(mousex+24,mousey+13,11);
           setcolor(15);
           sengjiao(lyear%12+1);
           rectangle(mousex+11,mousey+25,mousex+22,mousey+39);
 
if(cou==1)
           {
             setcolor(14);
             rectangle(mousex+11,mousey+25,mousex+22,mousey+39);
             setfillstyle(SOLID_FILL,7);
             floodfill(mousex+12,mousey+30,14);
             drawmat(run,12,mousex+11,mousey+27,11);
            }
           }
           else if(mousex>160&&y<=352)
           {
            drawmat(nong,12,mousex-65,mousey+10,col++);
           drawmat(li,12,mousex-65,mousey+30,col);
           rectangle(mousex-50,mousey+10,mousex,mousey+40);
           rectangle(mousex-49,mousey+11,mousex-1,mousey+39);
           setfillstyle(SOLID_FILL,13);
           floodfill(mousex-35,mousey+13,11);
           setcolor(15);
           sengjiao(lyear%12+1);
           rectangle(mousex-49,mousey+25,mousex-38,mousey+39);
           if(cou==1)
           {
           setcolor(14);
           rectangle(mousex-49,mousey+25,mousex-38,mousey+39);
           setfillstyle(SOLID_FILL,7);
           floodfill(mousex-47,mousey+30,14);
           drawmat(run,12,mousex-49,mousey+27,11);
           }
           }
     }
           }
          }
     }
     mousemove();

     if(bioskey(1))
     {
        key=bioskey(0);
          if(key==TAB)
       {
         count1=timer[count1].count;
         k=timer[count1].times;
        }
        if(key==LEFT)
        {
          k--;count1--;
          if(k==0)
          {k=4;
           count1=3;
          }
        }
        if(key==RIGHT)
        {
         k++;
         count1++;
          if(k==5)
          {k=1;
           count1=0;
          }
        }
      tab(k,key);
        choose(x,y,k);
        if(key==ESC)
        exit(1);
     }
   }
   sound1();
   } while(1);

}
 
void facegraph(int x,int y)
{
drawmat(ri1,24,x-356,y-138,WHITE);
drawmat(qi,24,x-330,y-138,WHITE);
outtextxy(x-305,y-125,"(D)");
drawmat(shi1,24,x-90,y-138,WHITE);
drawmat(jian,24,x-64,y-138,WHITE);
outtextxy(x-39,y-125,"(T)");
setcolor(7);
  setlinestyle(0,0,3);
  arc(x-369,y-258,90,180,12);
  setlinestyle(0,0,3);
   arc(x+108,y-258,0,90,12);
  setlinestyle(0,0,3);
line(x-380,y+110,x+121,y+110);
line(x-380,y-258,x-380,y+109);
line(x-368,y-270,x+109,y-270);
line(x+120,y-258,x+120,y+109);
line(x-380,y-258,x+120,y-258);
line(x-374,y-264,x-153,y-264);
line(290,56,514,56);  /*画主体框架*/
setlinestyle(0,0,1);
rectangle(x-365,y-140,x-100,y+90);
rectangle(x-95,y-140,x+107,y+90);
line(x-365,y-115,x-100,y-115);
line(x-95,y-115,x+107,y-115);
line(x-365,y-98,x-300,y-98);
line(x-95,y-98,x-77,y-98);
line(x-365,y-105,x-300,y-105);
line(x-95,y-105,x-77,y-105);
line(x-365,y-91,x-300,y-91);
line(x-95,y-91,x-77,y-91);
line(x-215,y-105,x-100,y-105);
line(x+90,y-105,x+107,y-105);
line(x-215,y-98,x-100,y-98);
line(x+90,y-98,x+107,y-98);
line(x-215,y-91,x-100,y-91);
line(x+90,y-91,x+107,y-91);
setcolor(12);
line(x-365,y-83,x-100,y-83);
line(x-365,y-65,x-100,y-65);
line(x-95,y-83,x+107,y-83);
line(x-95,y-65,x-51,y-65);
line(x+51,y-65,x+107,y-65);
circle(x,y,66);
circle(x,y,81);
setfillstyle(SOLID_FILL,14);
floodfill(x-80,y,12);
setcolor(WHITE);
   rectangle(60+200,60+75,80+200,80+75); /*down*/
  line(70+200,65+75,70+200,75+75);
  line(65+200,70+75,70+200,75+75);
  line(75+200,70+75,70+200,75+75);
  rectangle(40+200,60+75,60+200,80+75);/*left*/
  line(55+200,70+75,35+200,70+75);
  line(50+200,65+75,35+200,70+75);
  line(50+200,75+75,35+200,70+75);
  rectangle(80+200,60+75,100+200,80+75); /*right*/
  line(85+200,70+75,105+200,70+75);
  line(90+200,65+75,105+200,70+75);
  line(90+200,75+75,105+200,70+75);
  rectangle(60+200,40+75,80+200,60+75); /*up*/
  line(70+200,55+75,70+200,45+75);
  line(65+200,50+75,70+200,45+75);
  line(75+200,50+75,70+200,45+75);
  outtextxy(x-350,y-250,"control key : Up, Down, Left, Right, Esc, Tab");
  outtextxy(60+203,60+45,"Up");
  outtextxy(55+202,70+90,"Down");
  outtextxy(80+225,60+82,"Right");
  outtextxy(40+165,60+82,"Left");
}
main()
{
    int cx=400,cy=320;
    graph();
    setbkcolor(1);
    facegraph(cx,cy);
    clock(cx,cy);
    getch();
    closegraph();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -