一个计算机自动作图程序

 

None.gif // 你可以用上、下、左、右、Home,Page Up,End,Page Down来辅助计算机作图,也可以稍作修改自 // 己作图,如有Bug,请通知我,谢谢。
None.gif
None.gif
// 程序将在左上角显示正常大小的图符,并在右边显示一个放大一倍的非精细图符。
None.gif

None.gif#include #include #include #include #include 
None.gif
None.gif
#define  EXPAND 1#define BASEX 50#define BASEY 50
None.gif
ExpandedBlockStart.gifContractedBlock.gif
void  main() dot.gif int mode(int), PutIcon(int image[100][100], intint), x, y, image[100][100], Init(int image[100][100]), PutPoint(intintint); int Edit(int image[100][100]), Save(int image[100][100]);
InBlock.gif
InBlock.gifmode(
16); Init(image);
InBlock.gif
InBlock.gif
for (y = 1; y < 480; y++for (x = 1; x < 640; x++) PutPoint (x, y, 7);
InBlock.gif
ExpandedBlockEnd.gifEdit(image); Save(image); getch(); mode(
3); }

None.gif
ExpandedBlockStart.gifContractedBlock.gif
int  mode( int  value) dot.gif { union REGS r; r.h.ah = 0; r.h.al = value;
InBlock.gif
ExpandedBlockEnd.gifint86(
0x10&r, &r); return 1; }

None.gif
ExpandedBlockStart.gifContractedBlock.gif
int  PutPoint( int  x,  int  y,  int  color) dot.gif { union REGS r;
InBlock.gif
InBlock.gifr.h.ah 
= 12; r.h.bh = 0; r.h.al = color; r.x.cx = x; r.x.dx = y;
InBlock.gif
ExpandedBlockEnd.gifint86(
0x10&r, &r); return 1; }

None.gif
ExpandedBlockStart.gifContractedBlock.gif
int  PutIcon( int  image[ 100 ][ 100 ],  int  x,  int  y) dot.gif {
InBlock.gif
InBlock.gif
for (y = BASEY; y < 100+BASEY; y++for (x = BASEX; x < 100+BASEX; x++) PutPoint (x, y, image[y-BASEY][x-BASEX]);
InBlock.gif
InBlock.gif
for (y = BASEY+50; y < 100+BASEY+50; y++for (x = BASEX+300; x < 100+BASEX+300; x++) PutPoint (x+(x-BASEX-300)*EXPAND, y+(y-BASEY-50)*EXPAND, image[y-BASEY-50][x-BASEX-300]);
InBlock.gif
ExpandedBlockEnd.gif
return 0; }

None.gif
ExpandedBlockStart.gifContractedBlock.gif
int  Init( int  image[ 100 ][ 100 ]) dot.gif int i, j; FILE *fp;
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
if ((fp = fopen("data.pic""rb")) != NULL) dot.gif{ fread(image, sizeof(image), 1, fp); fclose(fp); } else dot.giffor (i = 0; i < 100; i++for (j = 0; j < 100; j++) image[i][j] = BLUE; } return 1; }

None.gif
ExpandedBlockStart.gifContractedBlock.gif
int  Cls() dot.gif { union REGS r;
InBlock.gif
InBlock.gifr.h.ah 
= 6; r.h.al = 0; r.h.bh = 7; r.h.ch = 0; r.h.cl = 0; r.h.dh = 24; r.h.dl = 79;
InBlock.gif
ExpandedBlockEnd.gifint86(
0x10&r, &r); return 0; }

None.gif
ExpandedBlockStart.gifContractedBlock.gif
int  Edit( int  image[ 100 ][ 100 ]) dot.gif int pen = GREEN; int x, y, key = 0x4800, GetKey(), k2, k1; struct time t1, t2; x = BASEX; y = BASEY;
InBlock.gif
InBlock.gifPutIcon(image, BASEX, BASEY); randomize(); gettime(
&t1);
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
dodot.gif{
InBlock.gif
InBlock.gif
if (bioskey(1)) //manual control key = GetKey(); else { gettime(&t2); //computer control if (t2.ti_sec != t1.ti_sec) //time distance { do{ k1 = rand()%9;
InBlock.gif

ExpandedSubBlockEnd.gif
if (k2 > k1 && k2 == k1+1continueelse if (k2 < k1 && k2 == k1-1continueelse break; }
while(1);
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
switch(k1) dot.gifcase 1: key = 0x4800breakcase 2: key = 0x5000breakcase 3: key = 0x4b00breakcase 4: key = 0x4d00breakcase 5: key = 0x4700breakcase 6: key = 0x4900breakcase 7: key = 0x5100breakcase 8: key = 0x4f00breakdefaultbreak; } t1.ti_sec = t2.ti_sec; }
 }
None.gif
None.gifdelay(
100 );
None.gif
ExpandedBlockStart.gifContractedBlock.gif
switch (key)  dot.gif case 0x4800if (y > BASEY) dot.gif{ y--; k2 = k1; } breakcase 0x5000if (y < BASEY+100dot.gif{ y++; k2 = k1; } breakcase 0x4b00if (x > BASEX) dot.gif{ x--; k2 = k1; } breakcase 0x4d00if (x < BASEX+100dot.gif{ x++; k2 = k1; } breakcase 0x4700if (x > BASEX && y > BASEY) dot.gif{ x--; y--; k2 = k1; } breakcase 0x4900if (x < BASEX+100 && y > BASEY) dot.gif{ x++; y--; k2 = k1; } breakcase 0x5100if (x < BASEX+100 && y < BASEY+100dot.gif{ x++; y++; k2 = k1; } breakcase 0x4f00if (x > BASEX && y < BASEY+100dot.gif{ x--; y++; k2 = k1; } breakdefault : break; }
None.gif
None.gifimage[x
- BASEX][y - BASEY]  =  pen; PutPoint(x, y, image[x - BASEX][y - BASEY]); PutPoint(x + 600 + (x - BASEX - 300 ) * EXPAND, y + 100 + (y - BASEY - 50 ) * EXPAND, image[x - BASEX][y - BASEY]); } while (key  !=   0x011b );
None.gif
None.gif
return   1 ; }
None.gif
ExpandedBlockStart.gifContractedBlock.gif
int  GetKey() dot.gif int key;
InBlock.gif
InBlock.gifkey 
= bioskey(0);
InBlock.gif
ExpandedBlockEnd.gif
return key; }

None.gif
ExpandedBlockStart.gifContractedBlock.gif
int  Save( int  image[ 100 ][ 100 ]) dot.gif { FILE *fp;
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
if ((fp = fopen("data.pic""wb")) == NULL) dot.gif{ printf ("\nError Open File!"); return 0; }
InBlock.gif
InBlock.giffwrite(image, 
sizeof(image), 1, fp); fclose(fp);
InBlock.gif
ExpandedBlockEnd.gif
return 1; }

None.gif
None.gif
None.gif
None.gif
None.gif
posted on 2006-03-02 21:48 Aween's Blog 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/aween/archive/2006/03/02/341531.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值