Header file:
graphics.h
Synopsis:
void setlinestyle (int linestyle, int upattern, int thickness);
Description:
setlinestyle() sets the current line style, pattern and thickness.
setlinestyle function in c graphics
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <conio.h>
int main(void) {
/* request auto detection */
int graphicDriver = DETECT, graphicMode;
int i, err, midx, midy;
char linestyle[5][32] = {"SOLID_LINE", "DOTTED_LINE",
"CENTERED_LINE", "DASHED_LINE"};
/* initialize graphics and local variables */
initgraph(&graphicDriver, &graphicMode, "C:/TURBOC3/BGI");
/* read result of initialization */
err = graphresult();
if (err != grOk) {
/* error occurred */
printf("Graphic Error: %s\n",
grapherrormsg(err));
return 0;
}
/* mid position in x and y-axis */
midx = getmaxx() / 2;
midy = getmaxy() / 2;
for (i = 0; i < 4; i++) {
/* clears graphic screen */
cleardevice();
/* setting the line style */
setlinestyle(i, 1, THICK_WIDTH);
/* drawing line from (0, 150) to (getmaxx(), 150) */
line(0, 150, getmaxx(), 150);
/* moving the current position to (midx, midy) */
moveto(midx, midy);
/* setting the text style */
settextstyle(TRIPLEX_FONT, HORIZ_DIR, 4);
settextjustify(CENTER_TEXT, CENTER_TEXT);
/* prints the given string */
outtext(linestyle[i]);
getch();
}
/* clean up */
getch();
closegraph();
return 0;
}
Output: (setlinestyle built-in function in c graphics.h)
No comments:
Post a Comment