例14: #include #include int main() { int i, gdriver, gmode; char s[30]; gdriver=DETECT; initgraph(&gdriver, &gmode, ""); setbkcolor(BLUE); cleardevice(); setviewport(100, 100, 540, 380, 1); /*定义一个图形窗口*/ setfillstyle(1, 2); /*绿色以实填充*/ setcolor(YELLOW); rectangle(0, 0, 439, 279); floodfill(50, 50, 14); setcolor(12); settextstyle(1, 0, 8); /*三重笔划字体, 水平放大8倍*/ outtextxy(20, 20, "Good Better"); setcolor(15); settextstyle(3, 0, 5); /*无衬笔划字体, 水平放大5倍*/ outtextxy(120, 120, "Good Better"); setcolor(14); settextstyle(2, 0, 8); i=620; sprintf(s, "Your score is %d", i); /*将数字转化为字符串*/ outtextxy(30, 200, s); /*指定位置输出字符串*/ setcolor(1); settextstyle(4, 0, 3); outtextxy(70, 240, s); getch(); closegraph(); return 0; }
三、用户对文本字符大小的设置 前面介绍的settextstyle()函数, 可以设定图形方式下输出文本字符这字体 和大小但对于笔划型字体(除8*8点阵字以个的字体), 只能在水平和垂直方向以 相同的放大倍数放大。为此Turbo C2.0又提供了另外一个setusercharsize() 函 数, 对笔划字体可以分别设置水平和垂直方向的放大倍数。该函数的调用格式为: void far setusercharsize(int mulx, int divx, int muly, int divy); 该函数用来设置笔划型字和放大系数, 它只有在settextstyle( ) 函数中的
上一篇:C++ 代码优化
下一篇:C语言图形处理
|