setlinestyle function of c graphic


C program to set the different line style

setlinestyle function is used to set the line style.

General syntax of setlinestyle function is :
              setlinestyle( int linestyle, unsigned upattern, int thickness);

It takes 3 argument first one is the line style. There are following line style available with the setlinestyle function with its corresponding integer value.

Line Styleint value
SOLID_LINE0
DOTTED_LINE1
CENTER_LINE2
DASHED_LINE3
USERBIT_LINE4

                                     The second argument is to use bit pattern and last one is for line's thickness it can be 1 pixel or 3 pixel wide.

C graphic program to demonstrate setlinestyle function 


#include <graphics.h>
#include <stdio.h>



int main( )
{
    int gd=DETECT, gm;
    initgraph(&gd,&gm,"C:\\tc\\bgi");

    setlinestyle(1,1,1);
    line(100,100,400,100);

    setlinestyle(DASHED_LINE,1,3);
    line(100,150,400,150);

    setlinestyle(2,1,1);
    line(100,200,400,200);


    getch();
    closegraph();

    return 0;
}



setlinestyle function of c graphics

Download



0 comments:

Post a Comment