C语言中的setlinestyle()函数

头文件显示图形。h包含 setlinestyle() 函数,用于设置由line、lineto、rectangle、drawpoly等绘制的所有线条的样式。

null

语法:

void setlinestyle(int linestyle, unsigned upattern,
                                   int thickness);

例如:

Input : x = 200, y = 100
Output : 图片[1]-C语言中的setlinestyle()函数-yiteyi-C++库

x and y are initialized as (200, 100). 
For every line, value of y increments 
by 25 to change the position. 
The line style keep changing corresponding
to value of first parameter(c). 

说明: 线型 指定将以几种样式中的哪一种绘制后续线条(例如实线、虚线、居中线和虚线)。 图片[2]-C语言中的setlinestyle()函数-yiteyi-C++库 升级模式 是一种16位模式,仅当linestyle为USERBIT_LINE(4)时才适用。在这种情况下,每当模式字中的一位为1时,该行中相应的像素将以当前绘制颜色绘制。必须始终提供“upattern”的值。如果“linestyle”不是USERBIT_LINE(4),那么它将被忽略。 指定后续绘制线条的宽度是普通还是粗。 图片[3]-C语言中的setlinestyle()函数-yiteyi-C++库

下面是setlinestyle()函数的实现:

// C Implementation for setlinestyle()
#include <graphics.h>
// driver code
int main()
{
// gm is Graphics mode which is
// a computer display mode that
// generates image using pixels.
// DETECT is a macro defined in
// "graphics.h" header file
int gd = DETECT, gm;
// variable to change the
// line styles
int c;
// initial coordinate to
// draw line
int x = 200, y = 100;
// initgraph initializes the
// graphics system by loading a
// graphics driver from disk
initgraph(&gd, &gm, "" );
// To keep track of lines
for ( c = 0 ; c < 5 ; c++ )
{
// setlinestyle function
setlinestyle(c, 0, 1);
// Drawing line
line(x, y, x+200, y);
y = y + 25;
}
getch();
// closegraph function closes the
// graphics mode and deallocates
// all memory allocated by
// graphics system .
closegraph();
return 0;
}


输出:

图片[4]-C语言中的setlinestyle()函数-yiteyi-C++库
© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享