<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>outtextxy | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/outtextxy/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Sat, 10 Dec 2022 04:31:14 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>Turbo C graphics programming</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/turbo-c-graphics-programming/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/turbo-c-graphics-programming/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Thu, 20 Nov 2008 10:45:39 +0000</pubDate>
				<category><![CDATA[C Tutorials]]></category>
		<category><![CDATA[c graphics]]></category>
		<category><![CDATA[initgraph]]></category>
		<category><![CDATA[circle]]></category>
		<category><![CDATA[outtextxy]]></category>
		<category><![CDATA[rectangle]]></category>
		<category><![CDATA[ellipse]]></category>
		<category><![CDATA[line]]></category>
		<category><![CDATA[sector]]></category>
		<category><![CDATA[arc]]></category>
		<category><![CDATA[pieslice]]></category>
		<category><![CDATA[drawpoly]]></category>
		<category><![CDATA[fillpoly]]></category>
		<category><![CDATA[setfillstyle]]></category>
		<category><![CDATA[bar]]></category>
		<category><![CDATA[Turbo C graphics]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=254</guid>

					<description><![CDATA[<p>To start with graphics programming, Turbo C is a good choice. Even though DOS has its own limitations,  it is having a large number of  useful functions and is easy to program. To implement graphics algorithms,  To give graphical display of statistics, To view signals from any source, we can use C graphics. Here  is </p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/turbo-c-graphics-programming/">Turbo C graphics programming</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>To start with graphics programming, Turbo C is a good choice. Even though DOS has its own limitations,  it is having a large number of  useful functions and is easy to program. To implement graphics algorithms,  To give graphical display of statistics, To view signals from any source, we can use C graphics. Here  is  a article to start programming  with  Turbo  C. &#8216;Run and Learn&#8217; is  our   method.   We  have  used source codes throughout the explanations. Just  execute  them to understand what is happening.</p>
<p>Turbo C has a good collection of graphics libraries. If you know the basics of C, you can easily learn graphics programming. To start programming, let us write a small program that displays a circle on the screen.</p>
<p>/* simple.c<br />
example 1.0<br />
*/<br />
#include&lt;graphics.h&gt;<br />
#include&lt;conio.h&gt;</p>
<p>void main()<br />
{<br />
int gd=DETECT, gm;</p>
<p>initgraph(&amp;gd, &amp;gm, &#8220;c:\\turboc3\\bgi &#8221; );<br />
circle(200,100,150);</p>
<p>getch();<br />
closegraph();<br />
}</p>
<p>To run this program, you need graphics.h header file, graphics.lib library file and Graphics driver (BGI file) in the program folder. These files are part of Turbo C package. In all our programs we used 640&#215;480 VGA monitor. So all the programs are according to that specification. You need to make necessary changes to your programs according to your screen resolution. For VGA monitor, graphics driver used is EGAVGA.BGI.</p>
<p>Here, initgraph() function initializes the graphics mode and clears the screen. We will study the difference between text mode and graphics mode in detail latter.</p>
<p><strong> InitGraph: </strong> Initializes the graphics system.</p>
<p>Declaration:  void far initgraph(int far *graphdriver, int far *graphmode, char far *pathtodriver);</p>
<p>Remarks: To start the graphics system, you must first call initgraph.</p>
<p>initgraph initializes the graphics system by loading a graphics driver from disk (or validating a registered driver) then putting the system into graphics mode.</p>
<p>initgraph also resets all graphics settings (color, palette, current position, viewport, etc.) to their defaults, then resets graphresult to 0.<br />
Arguments:</p>
<p>*graphdriver: Integer that specifies the graphics driver to be used. You can give graphdriver a value using a constant of the graphics drivers enumeration type.</p>
<p>*graphmode : Integer that specifies the initial graphics mode (unless *graphdriver = DETECT). If *graphdriver = DETECT, initgraph sets *graphmode to the highest resolution available for the detected driver. You can give *graphmode a value using a constant of the graphics_modes enumeration type.</p>
<p>pathtodriver : Specifies the directory path where initgraph looks for graphics drivers (*.BGI) first.  If they&#8217;re not there, initgraph looks in the current directory.  If pathtodriver is null, the driver files must be in the current directory.  This is also the path settextstyle searches for the stroked character font files (*.CHR).</p>
<p>closegraph() function switches back the screen from graphcs mode to text mode. It clears the screen also. A graphics program should have a closegraph function at the end of graphics. Otherwise DOS screen will not go to text mode after running the program. Here, closegraph() is called after getch() since screen should not clear until user hits a key.</p>
<p>If you have the BGI file in the same folder of your program, you can just leave it as &#8220;&#8221; only. you need not mention *graphmode if you give *graphdriver as DETECT.</p>
<p>In graphics mode, all the screen co-ordinates are mentioned in terms of pixels. Number of pixels in the screen decides resolution of the screen. In the example 1.0,  circle is drawn with x-coordinate of the center 200, y-coordinate 100 and radius 150 pixels. All the coordinates are mentioned with respect to top-left corner of the screen.</p>
<p><strong>Basic Shapes and Colors:</strong></p>
<p>Now let us write a program to draw some basic shapes.</p>
<p>/*<br />
shapes.c<br />
example 1.1<br />
*/</p>
<p>#include&lt;graphics.h&gt;<br />
#include&lt;conio.h&gt;</p>
<p>void main()<br />
{<br />
int gd=DETECT, gm;<br />
int poly[12]={350,450, 350,410, 430,400, 350,350, 300,430, 350,450 };<br />
initgraph(&amp;gd, &amp;gm, &#8220;&#8221;);</p>
<p>circle(100,100,50);<br />
outtextxy(75,170, &#8220;Circle&#8221;);<br />
rectangle(200,50,350,150);<br />
outtextxy(240, 170, &#8220;Rectangle&#8221;);<br />
ellipse(500, 100,0,360, 100,50);<br />
outtextxy(480, 170, &#8220;Ellipse&#8221;);<br />
line(100,250,540,250);<br />
outtextxy(300,260,&#8221;Line&#8221;);</p>
<p>sector(150, 400, 30, 300, 100,50);<br />
outtextxy(120, 460, &#8220;Sector&#8221;);<br />
drawpoly(6, poly);<br />
outtextxy(340, 460, &#8220;Polygon&#8221;);<br />
getch();<br />
closegraph();<br />
}</p>
<p>Here is the screenshot of output:</p>
<figure id="attachment_255" aria-describedby="caption-attachment-255" style="width: 500px" class="wp-caption aligncenter"><img decoding="async" class="size-full wp-image-255" title="Output of above program" src="https://studentprojects.in/wp-content/uploads/2008/11/c_grap1.gif" alt="Output of above program" width="500" height="375" /><figcaption id="caption-attachment-255" class="wp-caption-text">Output of above program</figcaption></figure>
<p>Here, circle() function takes x, y coordinates of the circle with respect to left top of the screen and radius of the circle in terms of pixels as arguments. Not that, in graphics, almost all the screen parameters are measured in terms of pixels.</p>
<p>Function outtextxy() displays a string in graphical mode. You can use different fonts, text sizes, alignments, colors and directions of the text that we will study later. Parameters passed are x and y coordinates of the position on the screen where text is to be displayed. There is another function outtext() that displays a text in the current position. Current position is the place where last drawing is ended. These functions are declared as follows:</p>
<p>void far outtextxy(int x, int y, char *text);<br />
void far outtext(char *text);</p><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/turbo-c-graphics-programming/">Turbo C graphics programming</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/turbo-c-graphics-programming/feed/</wfw:commentRss>
			<slash:comments>40</slash:comments>
		
		
			</item>
	</channel>
</rss>
