📄 fs.htm
字号:
功 能: 画并填充椭圆扇区 <br>
用 法: void far sector(int x, int y, int stangle, int
endangle); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; <br>
int midx, midy, i; <br>
int stangle = 45, endangle = 135; <br>
int xrad = 100, yrad = 50; </p>
<p> /* initialize graphics and local variables */ <br>
initgraph(&gdriver, &gmode, ""); </p>
<p> /* read result of initialization */ <br>
errorcode = graphresult(); <br>
if (errorcode != grOk) /* an error occurred */
<br>
{ <br>
printf("Graphics error:
%s\n", grapherrormsg(errorcode)); <br>
printf("Press any key to
halt:"); <br>
getch(); <br>
exit(1); /* terminate with an
error code */ <br>
} </p>
<p> midx = getmaxx() / 2; <br>
midy = getmaxy() / 2; </p>
<p> /* loop through the fill patterns */ <br>
for (i=EMPTY_FILL; i<USER_FILL; i++) <br>
{ <br>
/* set the fill style */ <br>
setfillstyle(i, getmaxcolor()); </p>
<p> /* draw the sector slice */ <br>
sector(midx, midy, stangle,
endangle, xrad, yrad); </p>
<p> getch(); <br>
} </p>
<p> /* clean up */ <br>
closegraph(); <br>
return 0; <br>
} <br>
</p>
<p>函数名: segread <br>
功 能: 读段寄存器值 <br>
用 法: void segread(struct SREGS *segtbl); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <dos.h> </p>
<p>int main(void) <br>
{ <br>
struct SREGS segs; </p>
<p> segread(&segs); <br>
printf("Current segment register
settings\n\n"); <br>
printf("CS: %X DS: %X\n",
segs.cs, segs.ds); <br>
printf("ES: %X SS: %X\n",
segs.es, segs.ss); </p>
<p> return 0; <br>
} <br>
<br>
</p>
<p>函数名: setactivepage <br>
功 能: 设置图形输出活动页 <br>
用 法: void far setactivepage(int pagenum); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* select a driver and mode that supports */ <br>
/* multiple pages.
*/ <br>
int gdriver = EGA, gmode = EGAHI, errorcode; <br>
int x, y, ht; </p>
<p> /* initialize graphics and local variables */ <br>
initgraph(&gdriver, &gmode, ""); </p>
<p> /* read result of initialization */ <br>
errorcode = graphresult(); <br>
if (errorcode != grOk) /* an error occurred */
<br>
{ <br>
printf("Graphics error:
%s\n", grapherrormsg(errorcode)); <br>
printf("Press any key to
halt:"); <br>
getch(); <br>
exit(1); /* terminate with an
error code */ <br>
} </p>
<p> x = getmaxx() / 2; <br>
y = getmaxy() / 2; <br>
ht = textheight("W"); </p>
<p> /* select the off screen page for drawing
*/ <br>
setactivepage(1); </p>
<p> /* draw a line on page #1 */ <br>
line(0, 0, getmaxx(), getmaxy()); </p>
<p> /* output a message on page #1 */ <br>
settextjustify(CENTER_TEXT, CENTER_TEXT); <br>
outtextxy(x, y, "This is page #1:"); <br>
outtextxy(x, y+ht, "Press any key to
halt:"); </p>
<p> /* select drawing to page #0 */ <br>
setactivepage(0); </p>
<p> /* output a message on page #0 */ <br>
outtextxy(x, y, "This is page #0."); <br>
outtextxy(x, y+ht, "Press any key to view page
#1:"); <br>
getch(); </p>
<p> /* select page #1 as the visible page */ <br>
setvisualpage(1); </p>
<p> /* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: setallpallette <br>
功 能: 按指定方式改变所有的调色板颜色 <br>
用 法: void far setallpallette(struct palette, far
*pallette); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; <br>
struct palettetype pal; <br>
int color, maxcolor, ht; <br>
int y = 10; <br>
char msg[80]; </p>
<p> /* initialize graphics and local variables */ <br>
initgraph(&gdriver, &gmode, ""); </p>
<p> /* read result of initialization */ <br>
errorcode = graphresult(); <br>
if (errorcode != grOk) /* an error occurred */
<br>
{ <br>
printf("Graphics error:
%s\n", grapherrormsg(errorcode)); <br>
printf("Press any key to
halt:"); <br>
getch(); <br>
exit(1); /* terminate with an
error code */ <br>
} </p>
<p> maxcolor = getmaxcolor(); <br>
ht = 2 * textheight("W"); </p>
<p> /* grab a copy of the palette */ <br>
getpalette(&pal); </p>
<p> /* display the default palette colors */ <br>
for (color=1; color<=maxcolor; color++) <br>
{ <br>
setcolor(color); <br>
sprintf(msg, "Color:
%d", color); <br>
outtextxy(1, y, msg); <br>
y += ht; <br>
} </p>
<p> /* wait for a key */ <br>
getch(); </p>
<p> /* black out the colors one by one */ <br>
for (color=1; color<=maxcolor; color++) <br>
{ <br>
setpalette(color, BLACK); <br>
getch(); <br>
} </p>
<p> /* restore the palette colors */ <br>
setallpalette(&pal); </p>
<p> /* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: setaspectratio <br>
功 能: 设置图形纵横比 <br>
用 法: void far setaspectratio(int xasp, int yasp); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; <br>
int xasp, yasp, midx, midy; </p>
<p> /* initialize graphics and local variables */ <br>
initgraph(&gdriver, &gmode, ""); </p>
<p> /* read result of initialization */ <br>
errorcode = graphresult(); <br>
if (errorcode != grOk) /* an error occurred */
<br>
{ <br>
printf("Graphics error:
%s\n", grapherrormsg(errorcode)); <br>
printf("Press any key to
halt:"); <br>
getch(); <br>
exit(1); /* terminate with an
error code */ <br>
} </p>
<p> midx = getmaxx() / 2; <br>
midy = getmaxy() / 2; <br>
setcolor(getmaxcolor()); </p>
<p> /* get current aspect ratio settings */ <br>
getaspectratio(&xasp, &yasp); </p>
<p> /* draw normal circle */ <br>
circle(midx, midy, 100); <br>
getch(); </p>
<p> /* claer the screen */ <br>
cleardevice(); </p>
<p> /* adjust the aspect for a wide circle */ <br>
setaspectratio(xasp/2, yasp); <br>
circle(midx, midy, 100); <br>
getch(); </p>
<p> /* adjust the aspect for a narrow circle */ <br>
cleardevice(); <br>
setaspectratio(xasp, yasp/2); <br>
circle(midx, midy, 100); </p>
<p> /* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: setbkcolor <br>
功 能: 用调色板设置当前背景颜色 <br>
用 法: void far setbkcolor(int color); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* select a driver and mode that supports */ <br>
/* multiple background colors.
*/ <br>
int gdriver = EGA, gmode = EGAHI, errorcode; <br>
int bkcol, maxcolor, x, y; <br>
char msg[80]; </p>
<p> /* initialize graphics and local variables */ <br>
initgraph(&gdriver, &gmode, ""); </p>
<p> /* read result of initialization */ <br>
errorcode = graphresult(); <br>
if (errorcode != grOk) /* an error occurred */
<br>
{ <br>
printf("Graphics error:
%s\n", grapherrormsg(errorcode)); <br>
printf("Press any key to
halt:"); <br>
getch(); <br>
exit(1); /* terminate with an
error code */ <br>
} </p>
<p> /* maximum color index supported */ <br>
maxcolor = getmaxcolor(); </p>
<p> /* for centering text messages */ <br>
settextjustify(CENTER_TEXT, CENTER_TEXT); <br>
x = getmaxx() / 2; <br>
y = getmaxy() / 2; </p>
<p> /* loop through the available colors */ <br>
for (bkcol=0; bkcol<=maxcolor; bkcol++) <br>
{ <br>
/* clear the screen */ <br>
cleardevice(); </p>
<p> /* select a new background
color */ <br>
setbkcolor(bkcol); </p>
<p> /* output a messsage */ <br>
if (bkcol == WHITE) <br>
setcolor(EGA_BLUE); <br>
sprintf(msg, "Background
color: %d", bkcol); <br>
outtextxy(x, y, msg); <br>
getch(); <br>
} </p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -