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

📄 chakri.cpp

📁 this is a graphical editor similar to MS_PAINT built using c++ language runs on turbo c++ compiler
💻 CPP
📖 第 1 页 / 共 4 页
字号:
	    getmpos(&butt,&x,&y);
	 restrictmptr(1,39,638,478);
	 setfillstyle(1,bkgrnd);
	 bar(73,69,636,442);
	 setlinestyle(SOLID_LINE,USERBIT_LINE,1);
	 showmptr();
	 menuop=0;
	 butt=0;
	 return 0;
      }

      /* copying */

      if((x>231&&x<289)&&(y>105&&y<128)&&(butt==1)) {
	 hidemptr();
	 setfillstyle(1,15);
	 fillellipse(225,117,4,4);
	 settextstyle(4,0,2);
	 setcolor(DARKGRAY);
	 outtextxy(235,102,"Copy");
	 delay(300);
	 cleanup();
	 showmptr();
	 getmpos(&butt,&x,&y);
	 hope(9,cbut,0);
	 _save1(select);
	 butt=0;
	 while(butt!=1)
	    getmpos(&butt,&x,&y);
	 setcolor(bkgrnd);
	 if(select[3]>441)
	    select[3]=441;
	 if(select[2]>635)
	    select[2]=635;
	 if(select[1]<70)
	    select[1]=70;
	 if(select[0]<74)
	    select[0]=74;
	 rectangle(select[0]-1,select[1]-1,select[2]+1,select[3]+1);
	 showmptr();
	 menuop=0;
	 butt=0;
	 return 0;
      }

      /* pasting */

      if((x>231&&x<292)&&(y>135&&y<158)&&(butt==1)) {
	 hidemptr();
	 setfillstyle(1,15);
	 fillellipse(225,147,4,4);
	 settextstyle(4,0,2);
	 setcolor(DARKGRAY);
	 outtextxy(235,132,"Paste");
	 delay(300);
	 cleanup();
	 showmptr();
	 butt=0;
	 while(butt!=2) {
	    getmpos(&butt,&x,&y);
	    if(butt==1)
	       _load1(select,x,y);
	    showmptr();
	 }
	 menuop=0;
	 butt=0;
	 return 0;
      }
      else {
	 if(butt==1) {
	    butt=0;
	    menuop=0;
	    cleanup();
	    return 0;
	 }
      }
   }
   return 0;
}

/**************************************************/

viewop(int menuop,int cbut)
{
   int x,y,butt=0;
   restrictmptr(73,69,636,442);
   while(menuop==3) {
      getmpos(&butt,&x,&y);
      if((x>346&&x<396)&&(y>75&&y<96)&&(butt&1==1)) {
	 hidemptr();
	 setcolor(8);
	 outtextxy(355,72,"Line");
	 menuop=0;
	 setfillstyle(1,15);
	 fillellipse(345,87,4,4);
	 delay(300);
	 setfillstyle(1,0);
	 bar(73,69,636,442);
	 rotline();
	 setfillstyle(1,bkgrnd);
	 bar(73,69,636,442);
	 setcolor(LIGHTGRAY);
	 rectangle(335,45,385,63);
	 showmptr();
	 butt=0;
	 return 0;
      }
      else if((x>346&&x<408)&&(y>105&y<127)&&(butt&1==1)) {
	 hidemptr();
	 setcolor(8);
	 outtextxy(355,102,"Wheel");
	 menuop=0;
	 setfillstyle(1,15);
	 fillellipse(345,117,4,4);
	 delay(300);
	 setfillstyle(1,0);
	 bar(73,69,636,442);
	 rotwheel();//320,240);
	 setfillstyle(1,bkgrnd);
	 bar(73,69,636,442);
	 setcolor(LIGHTGRAY);
	 rectangle(335,45,385,63);
	 showmptr();
	 butt=0;
	 return 0;
      }
      else if((x>346&&x<489)&&(y>136&y<160)&&(butt&1==1)) {
	 hidemptr();
	 setcolor(8);
	 outtextxy(355,132,"Pyramid");
	 menuop=0;
	 setfillstyle(1,15);
	 fillellipse(345,147,4,4);
	 delay(300);
	 cleanup();
	 restrictmptr(73,69,636,442);
	 hope(8,cbut,0);
	 restrictmptr(1,39,638,478);
	 showmptr();
	 butt=0;
	 return 0;
      }
      else {
	 if(butt==1) {
	    butt=0;
	    menuop=0;
	    cleanup();
	    return 0;
	 }
      }
   }
   return 0;
}

//union REGS i,o;
int globkey=-1,patt=0;

int v=1;

main()
{
   cbut=9;bkgrnd=15;

   int gd=DETECT,gm,x,y,butt,i,j,cbu=0,option=0,a,b,x8,y8,menuop=0,x11,y11,x22,y22,flag=1;

   int xc=10,yc=29;
   int x1[12]={330,357,382,407,432,457,482,507,532,557,582,607};
   int x2[12]={353,378,403,428,453,478,503,528,553,578,603,632};
   int x3[8]={70,101,133,164,196,226,257,288};
   int x4[8]={98,129,160,192,223,253,284,316};
   int x5[14][4]={9,71,35,108,36,71,61,108,9,110,35,146,36,110,61,146,
		  9,148,35,184,36,148,61,184,9,186,35,222,36,186,61,222,
		  9,224,35,260,36,224,61,260,9,262,35,300,36,262,61,300,
		  9,302,35,339,36,302,61,339};
   int arr[25],colour=1;

   initgraph(&gd,&gm,"c:\\tc\\bgi");
   cleardevice();
   /* calling interface program */
   inter();
   /* logical main program*/
   while(flag) {
      /* time box */
      {
	 struct time t;
	 gettime(&t);
	 gotoxy(1,24);
	 textcolor(GREEN);
	 printf("%2d:%2d:%2d ",t.ti_hour,t.ti_min,t.ti_sec);
      }
      /* to print mouse position */
	      getmpos(&butt,&x,&y);
      gotoxy(2,4);
      printf("%03d %03d",x,y);
      /* help menu bar */
      help(x,y);
      /* left click colour select */
      setfillstyle(1,BLACK);
      bar(2,8,638,39);
      line(1,39,638,39);

      settextstyle(1,0,2);

      if(xc>600) {
	 if(colour>=15)
	    colour=1;
	 v=-1;
	 colour++;
      }
      else {
	 if(xc<-150) {
	    v=1;
	    if(colour>=15)
	       colour=1;
	    colour++;
	 }
      }
      setcolor(MAGENTA);
      settextstyle(1,0,2);
      outtextxy(xc,10,"GRAPHICS PACKAGE");

      delay(40);

      xc=xc+10*v;

      if((x>70&&x<316)&&(y>448&&y<473)&&(butt&1==1)) {
	 cbut=selecolor(x3,x4,x,y,butt);
	 sound(15100);
	 changcol(cbut);
	 nosound();
      }
      /* left click pattern select */
      if((x>330&&x<633)&&(y>447&&y<458)&&(butt&1==1)) {
	 patt=selepat(x1,x2,x,y,&cbu,butt);
	 chngpat(cbu);
      }
      /* to draw a line */
      if((x>10&&x<33)&&(y>72&&y<107)&&(butt&1==1)) {
	 globkey=0;
	 hidemptr();
	 press(x5,globkey);
	 option=1;
	 restrictmptr(74,70,636,441);
	 hope(option,cbut,0);
	 restrictmptr(1,39,638,478);
	 option=0;
	 globkey=0;
	 depress(x5,globkey);
	 globkey=-1;
      }
      /* to use eraser */
      if((x>37&&x<60)&&(y>72&&y<108)&&(butt&1==1)) {
	 hidemptr();
	 restrictmptr(77,73,628,438);
	 globkey=1;
	 hidemptr();
	 press(x5,globkey);
	 showmptr();
	 eraser(globkey,bkgrnd);
	 restrictmptr(1,39,638,478);
	 showmptr();
	 globkey=1;
	 depress(x5,globkey);
	 globkey=-1;
      }
      /* to draw a circle */
      if((x>10&&x<33)&&(y>112&&y<146)&&(butt&1==1)) {
	 globkey=2;
	 hidemptr();
	 press(x5,globkey);
	 option=2;
	 restrictmptr(74,70,636,441);
	 setcolor(BLACK);
	 hope(option,cbut,patt);
	 showmptr();
	 restrictmptr(1,39,638,478);
	 option=0;
	 globkey=2;
	 depress(x5,globkey);
	 globkey=-1;
      }

      /* to paint screen */
      if((x>36&&x<61)&&(y>112&&y<146)&&(butt&1==1)) {
	 restrictmptr(77,73,633,438);
	 globkey=3;
	 hidemptr();
	 press(x5,globkey);
	 setcolor(cbut);
	 delay(300);
	 paint(globkey);
	 restrictmptr(1,39,638,478);
	 showmptr();
	 globkey=3;
	 depress(x5,globkey);
	 globkey=-1;
      }

      /* to draw a rectangle */
      if((x>10&&x<33)&&(y>149&&y<185)&&(butt&1==1)) {
	 globkey=4;
	 hidemptr();
	 press(x5,globkey);
	 option=3;
	 restrictmptr(74,70,636,441);
	 delay(300);
	 setcolor(BLACK);
	 hope(option,cbut,patt);
	 showmptr();
	 restrictmptr(1,39,638,478);
	 option=0;
	 globkey=4;
	 depress(x5,globkey);
	 globkey=-1;
      }

      /* to draw free hand */
      if((x>37&&x<60)&&(y>149&&y<185)&&(butt&1==1)) {
	 globkey=5;
	 hidemptr();
	 press(x5,globkey);
	 restrictmptr(74,70,636,441);
	 delay(300);
	 while(globkey==5) {
	    setcolor(cbut);
	    getmpos(&butt,&x,&y);
	    while(butt==1) {
	       hidemptr();
	       a=x; b=y;
	       getmpos(&butt,&x,&y);
	       line(a,b,x,y);
	       showmptr();
	    }
	    showmptr();
	    getmpos(&butt,&x,&y);
	    if(butt==2) {
	       depress(x5,globkey);
	       restrictmptr(1,39,638,475);
	       globkey=-1;
	    }
	 }
      }

      /* to draw an ellipse */
      if((x>10&&x<33)&&(y>187&&y<222)&&(butt&1==1)) {
	 globkey=6;
	 //hidemptr();
	 press(x5,globkey);
	 option=4;
	 showmptr();
	 restrictmptr(74,70,636,441);
	 delay(300);
	 setcolor(BLACK);
	 hope(option,cbut,patt);
	 showmptr();
	 restrictmptr(1,39,638,478);
	 option=0;
	 globkey=6;
	 depress(x5,globkey);
	 globkey=-1;
      }

      /* to draw a polygon */
      if((x>36&&x<61)&&(y>187&&y<222)&&(butt&1==1)) {
	 globkey=7;
	 //hidemptr();
	 press(x5,globkey);
	 showmptr();
	 restrictmptr(74,70,636,441);
	 delay(300);
	 showmptr();
	 setcolor(cbut);
	 getmpos(&butt,&x,&y);
	 while (butt!=1) {
	    getmpos(&butt,&x,&y);
	 }
	 x11=x;
	 y11=y;
	 showmptr();
	 while(globkey==7) {
	    while(butt!=1) {
	       getmpos(&butt,&x,&y);
	       if (butt==2)
		  break;
	    }
	    if (butt==2) {
	       restrictmptr(1,39,638,475);
	       depress(x5,globkey);
	       globkey=-1;
	       break;
	    }
	    x22=x;
	    y22=y;
	    hidemptr();
	    line(x11,y11,x22,y22);
	    showmptr();
	    x11=x22;
	    y11=y22;
	    getmpos(&butt,&x,&y);
	 }
	 showmptr();
      }

      /* to print text font */
      if((x>9&&x<34)&&(y>225&&y<260)&&(butt&1==1)) {
	 globkey=8;
	 // hidemptr();
	 press(x5,globkey);
	 option=1;
	 restrictmptr(74,70,636,441);
	 malla=1;
	 hope(option,cbut,0);
	 malla=0;
	 restrictmptr(1,39,638,478);
	 option=0;
	 globkey=8;
	 depress(x5,globkey);
	 globkey=-1;
      }

      /* clear screen function */
      if((x>37&&x<60)&&(y>225&&y<260)&&(butt&1==1)) {
	 globkey=9;
	 hidemptr();
	 press(x5,globkey);
	 setfillstyle(1,bkgrnd);
	 for(i=73;i<638;i++)
	    bar(i,69,i,442);
	 globkey=9;
	 depress(x5,globkey);
	 globkey=-1;
	 showmptr();
      }

      /* select and change background colour */
      if((x>9&&x<34)&&(y>263&&y<302)&&(butt&1==1)) {
	 globkey=10;
	 hidemptr();
	 press(x5,globkey);
	 for(i=69;i<=442;i++) {
	    for(j=73;j<=637;j++) {
	       if(getpixel(j,i)==bkgrnd)
		  putpixel(j,i,cbut);
	       else
		  continue;
	    }
	 }
	 bkgrnd=cbut;
	 globkey=10;
	 depress(x5,globkey);
	 globkey=-1;
	 showmptr();
      }

      /* to view 3d figures */
      if((x>37&&x<60)&&(y>262&&y<300)&&(butt&1==1)) {
	 globkey=11;
	 //hidemptr();
	 press(x5,globkey);
	 option=5;
	 restrictmptr(74,70,636,441);
	 delay(300);
	 setcolor(BLACK);
	 hope(option,cbut,0);
	 showmptr();
	 restrictmptr(1,39,638,478);
	 option=0;
	 globkey=11;
	 depress(x5,globkey);
	 globkey=-1;
      }

      /* to draw a cardioid */
      if((x>9&&x<34)&&(y>303&&y<340)&&(butt&1==1)) {
	 globkey=12;
	 //hidemptr();
	 press(x5,globkey);
	 option=6;
	 restrictmptr(74,70,636,441);
	 delay(300);
	 setcolor(cbut);
	 hope(option,cbut,0);
	 showmptr();
	 restrictmptr(1,39,638,478);
	 option=0;
	 while(globkey==12) {
	    getmpos(&butt,&x,&y);
	    if(butt==2) {
	       depress(x5,globkey);
	       globkey=-1;
	    }
	 }
      }

      /* to draw a spiral */
      if((x>36&&x<61)&&(y>303&&y<340)&&(butt&1==1)) {
	 globkey=13;
	 hidemptr();
	 press(x5,globkey);
	 option=7;
	 restrictmptr(74,70,636,441);
	 delay(300);
	 setcolor(cbut);
	 hope(option,cbut,0);
	 showmptr();
	 setcolor(15);
	 line(639,0,639,451);
	 setcolor(0);
	 line(638,0,638,451);
	 restrictmptr(1,39,638,478);
	 option=0;
	 while(globkey==13) {
	    getmpos(&butt,&x,&y);
	    if(butt==2) {
	       depress(x5,globkey);
	       globkey=-1;
	    }
	 }
      }

      /* file option */
      if((x>100&&x<132)&&(y>47&&y<60)&&(butt&1==1)) {
      //	char ch;
      // if(ch=='f'||ch=='F'){
	 menuop=1;
	 file();
	 showmptr();
	 fileop(menuop);
	 restrictmptr(1,39,638,478);
      //}
      }
      /* edit option */
      if((x>220&&x<255)&&(y>47&&y<60)&&(butt&1==1)) {
	 menuop=2;
	 edit();
	 showmptr();
	 editop(menuop,cbut,bkgrnd);
	 restrictmptr(1,39,638,478);
      }

      /* view option */
      if((x>340&&x<380)&&(y>47&&y<60)&&(butt&1==1)) {
	 menuop=3;
	 view();
	 showmptr();
	 viewop(menuop,cbut);
	 restrictmptr(1,39,638,478);
      }

      /* credits option */
      if((x>460&&x<520)&&(y>47&&y<60)&&(butt&1==1)) {
	 menuop=4;
	 credits();
	 showmptr();
	 while(menuop==4) {
	    getmpos(&butt,&x,&y);
	    if(butt==1) {
	       hidemptr();
	       setcolor(bkgrnd);
	       for(i=0;i<235;i++) {
		  line(124+i,125,124+i,375);
		  delay(10);
		  line(585-i,125,585-i,375);
	       }
	       showmptr();
	       cleanup();
	       menuop=0;
	    }
	 }
      }

      /* EXIT FUCTION */
      if((x>614&x<=631)&&(y>44&&y<62)&&(butt&1==1)) {
	 setcolor(BLACK);
	 line(612,43,630,43);
	 line(612,43,612,61);
	 setcolor(WHITE);
	 line(631,43,631,62);
	 line(612,62,630,62);
	 delay(200);
	 setcolor(WHITE);
	 line(612,43,630,43);
	 line(612,43,612,61);
	 setcolor(BLACK);
	 line(631,43,631,62);
	 line(612,62,630,62);
	 delay(500);
	 flag=0;
	 exit(1);
      }
   }
   return 0;
}

/* end of main*/

⌨️ 快捷键说明

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