头文件显示图形。h包含 setlinestyle() 函数,用于设置由line、lineto、rectangle、drawpoly等绘制的所有线条的样式。
null
语法:
void setlinestyle(int linestyle, unsigned upattern, int thickness);
例如:
Input : x = 200, y = 100 Output :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).
说明: 线型 指定将以几种样式中的哪一种绘制后续线条(例如实线、虚线、居中线和虚线)。 升级模式 是一种16位模式,仅当linestyle为USERBIT_LINE(4)时才适用。在这种情况下,每当模式字中的一位为1时,该行中相应的像素将以当前绘制颜色绘制。必须始终提供“upattern”的值。如果“linestyle”不是USERBIT_LINE(4),那么它将被忽略。 厚 指定后续绘制线条的宽度是普通还是粗。
下面是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; } |
输出:
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END