
- Forum
- Programming Talk
- C and C++
- Graphics Functions in C
Graphics Functions in C
This is a discussion on Graphics Functions in C within the C and C++ forums, part of the Programming Talk category; Hi, I was working with some graphics functions in C and I was struck with how to fill in the ...
-
Graphics Functions in C
Hi,
I was working with some graphics functions in C and I was struck with how to fill in the images(say ellipse/polygon/...) which will give only an outline.I have a doubt whether we will be able to do the above .If so what is the function used for that.Can someone highlight on this.
Sripriya
-
07-13-2006, 02:15 PM #2
Hi Priya,
Nice to see that you are making your hands dirty on graphics.. good.
to fill the ellipse ot polygon.. etc.. We hava a functions called..
setfillstyle(int pattern, int color);
color values will be from 0 to 15 (based on the color scheme you put VGA, SVGA,..)
Patterns include::
0 or " EMPTY_FILL"
1 or "SOLID_FILL"
2 or "LINE_FILL"
3 or "LTSLASH_FILL"
4 or "SLASH_FILL"
5 or "BKSLASH_FILL"
6 or "LTBKSLASH_FILL"
7 or "HATCH_FILL"
8 or "XHATCH_FILL"
9 or "INTERLEAVE_FILL"
10 or" WIDE_DOT_FILL"
11 or "CLOSE_DOT_FILL"
12 or "USER_FILL"
ie; you can write like this:: setfillstyle(1,11)
fillellipse(int screenx, int screeny, int x_radius, int y_radius);
fillpoly(int noof_vertices, int far *points)
the last vertex should be the first vertex.(inorder to close the poly)
points can be declared as follows::
the code can be as follows::
#include<graphics.h>
bla...bla bla..
main()
{
initialize graphics....
int ploy[8],i;
maxx = getmaxx();
maxy = getmaxy();
poly[0] = 20; /* 1st vertex */
poly[1] = maxy / 2;
poly[2] = maxx - 20; /* 2nd */
poly[3] = 20;
poly[4] = maxx - 50; /* 3rd */
poly[5] = maxy - 20;
/*
4th vertex. fillpoly automatically
closes the polygon.
*/
poly[6] = maxx / 2;
poly[7] = maxy / 2;
/* loop through the fill patterns */
for (i=EMPTY_FILL; i<USER_FILL; i++)
{
/* set fill pattern */
setfillstyle(i, getmaxcolor());
/* draw a filled polygon */
fillpoly(4, poly);
getch();
}
closegraph()
}
regards,
Aditya
-
Thank you Aditya. It was really a fantastic detailed explanation with example you gave. I got a detailed knowledge on this topic and even tried it and could get some images filled.
-
Hi nice discussion going around. I did not know anything about filling images before I read this discussion. This gave me an insight on this topic.Can you say me some more interesting graphics functions in this priyaraji and aditya or someone new to this discussion.
-
Sponsored Ads

Reply With Quote





