<?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>c graphics | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/c-graphics/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Mon, 31 Jan 2011 10:28:57 +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>C graphics program for analog clock</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-graphics-program-for-analog-clock/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-graphics-program-for-analog-clock/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Fri, 02 Oct 2009 12:51:49 +0000</pubDate>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[c graphics]]></category>
		<category><![CDATA[Source Codes]]></category>
		<category><![CDATA[digital clock]]></category>
		<category><![CDATA[clock in c]]></category>
		<category><![CDATA[analog clock]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[free]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=843</guid>

					<description><![CDATA[<p>Time_Dig[0]=hour/10+48;<br />
      Time_Dig[1]=hour%10+48;<br />
      Time_Dig[2]=':';<br />
      Time_Dig[3]=min/10+48;<br />
      Time_Dig[4]=min%10+48;<br />
      Time_Dig[5]=':';<br />
      Time_Dig[6]=sec/10+48;</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-graphics-program-for-analog-clock/">C graphics program for analog clock</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="c">
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<math.h>

#define arg_sec M_PI/30
#define arg_hour M_PI/6
#define arg_min M_PI/360
void main()
{
  int gd=DETECT,gm,sec=0,hour,min,x1=0,y1=0,x2=0,y2=0,x3=0,y3=0;
  char *k[12]={"1","2","3","4","5","6","7","8","9","10","11","12"};
  struct time t;
  initgraph(&gd,&gm,"");
  setcolor(YELLOW);
  circle(300,200,200);
  circle(300,200,180);
  setfillstyle(1,RED);
  floodfill(300,390,YELLOW);
  settextstyle(DEFAULT_FONT,0,2);
//----------------------Constants----------------------//

  int a,b;
  for(int i=1;i<13;i++)
    {
	a=160*cos(arg_hour*i-M_PI_2);
	b=160*sin(arg_hour*i-M_PI_2);
	outtextxy(a+300,b+200,k[i-1]);
    }

//----------------------Constants----------------------//
/*****************************************************
		 1-Good
		 2-Small
		 3-Watse
		 4-caligraphy
		 5-cursive
		 6-good
		 7-excellent
		 8-Good
		 9-Big
		 10-Double
 ****************************************************/
 int dig_sec;
 char Time_Dig[14];
  while(!kbhit())
   {
       settextstyle(7,0,4);
      outtextxy(264,100,"Satya");
      settextstyle(7,0,1);
      outtextxy(278,280,"Quartz");
      setcolor(BLACK);
      line(300,200,x1+300,y1+200);
      line(300,200,x2+300,y2+200);
      line(300,200,x3+300,y3+200);
      gettime(&#038;t);
      if(sec!=t.ti_sec)
	{
	   sound(5000);
	   delay(1);
	   nosound();
	}
      hour=t.ti_hour;
      sec=t.ti_sec;
      min=t.ti_min;
      Time_Dig[0]=hour/10+48;
      Time_Dig[1]=hour%10+48;
      Time_Dig[2]=':';
      Time_Dig[3]=min/10+48;
      Time_Dig[4]=min%10+48;
      Time_Dig[5]=':';
      Time_Dig[6]=sec/10+48;
      Time_Dig[7]=sec%10+48;
      Time_Dig[8]='\0';
      outtextxy(270,250,"ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
      x1=150*cos(arg_sec*sec-M_PI_2)*0.98;
      y1=150*sin(arg_sec*sec-M_PI_2)*0.98;
      x2=150*cos(arg_sec*min-M_PI_2)*0.9;
      y2=150*sin(arg_sec*min-M_PI_2)*0.9;
      if(hour>12) hour-=12;
      x3=150*cos(arg_hour*hour-M_PI_2+arg_min*min)*0.6;
      y3=150*sin(arg_hour*hour-M_PI_2+arg_min*min)*0.6;
      setcolor(YELLOW);
      line(300,200,x1+300,y1+200);
      setcolor(CYAN);
      line(300,200,x2+300,y2+200);
      setcolor(WHITE);
      line(300,200,x3+300,y3+200);
      setcolor(YELLOW);
      outtextxy(270,250,Time_Dig);
      delay(50);

   }

  getch();
  closegraph();
  restorecrtmode();
}
</pre>
<p><a href="https://studentprojects.in/wp-content/uploads/2009/10/Clock.zip"><br />
Click here</a> to download the source code.</p><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-graphics-program-for-analog-clock/">C graphics program for analog clock</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/graphics/c-graphics-program-for-analog-clock/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
		<item>
		<title>C Program to fill any given polygon using scan-line area filling algorithm</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-fill-any-given-polygon-using-scan-line-area-filling-algorithm/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-fill-any-given-polygon-using-scan-line-area-filling-algorithm/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Fri, 02 Oct 2009 10:34:38 +0000</pubDate>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[c graphics]]></category>
		<category><![CDATA[C Programs]]></category>
		<category><![CDATA[dos]]></category>
		<category><![CDATA[Data structure]]></category>
		<category><![CDATA[polygon]]></category>
		<category><![CDATA[filling algorithm]]></category>
		<category><![CDATA[filcolor]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=841</guid>

					<description><![CDATA[<p>setcolor (WHITE);<br />
    line (pt[0][0], pt[0][1], pt[1][0], pt[1][1]);<br />
    line (pt[1][0], pt[1][1], pt[2][0], pt[2][1]);<br />
    line (pt[2][0], pt[2][1], pt[0][0], pt[0][1]);<br />
    getch();</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-fill-any-given-polygon-using-scan-line-area-filling-algorithm/">C Program to fill any given polygon using scan-line area filling algorithm</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="c" escaped="true" line="1">
#include <graphics.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

struct Node
{
    int x;
    int y;
    struct Node* next;
};

void fill (int pt[][2], int clr);
void floodfill4 (int x, int y, int oldclr, int newclr);
void insert (int x, int y, struct Node** last);

void main()
{
    int i, j;
    int pt[3][2];
    int clr;

    printf ("This program demonstrates filling a polygon.\n");
    printf ("Enter the x- and y-coordinates for three points:\n");
    for (i=0; i<3; i++)
	for (j=0; j<2; j++)
	    scanf ("%d", &#038;pt[i][j]);

    printf ("Enter the fill-colour: (Any number from 1 to 14) ");
    scanf ("%d", &#038;clr);
    fill (pt, clr);
}

void fill (int pt[][2], int clr)
{
    int gd = DETECT, gm;
    int seedx, seedy;

    initgraph (&#038;gd, &#038;gm, "..\\bgi");

    setcolor (WHITE);
    line (pt[0][0], pt[0][1], pt[1][0], pt[1][1]);
    line (pt[1][0], pt[1][1], pt[2][0], pt[2][1]);
    line (pt[2][0], pt[2][1], pt[0][0], pt[0][1]);
    getch();

    seedx = (pt[0][0] + pt[1][0] + pt[2][0]) / 3;
    seedy = (pt[0][1] + pt[1][1] + pt[2][1]) / 3;

    floodfill4 (seedx, seedy, BLACK, clr);
    getch();

    closegraph();
    return;
}

void floodfill4 (int x, int y, int oldclr, int newclr)
{
    struct Node* first, *last, *tmp;

    first = (struct Node*) malloc (sizeof (struct Node));
    if (first == NULL)
    {
	closegraph();
	fprintf (stderr, "floodfill4: Out of memory.\n");
	exit (2);
    }
    if (oldclr == newclr)
    {
	free (first);
	return;
    }
   
    first->x = x;
    first->y = y;
    first->next = NULL;
    last = first;

    while (first != NULL)
    {
	putpixel (x, y, newclr);
	
	if (getpixel (x, y-1) == oldclr)
	{
	    putpixel (x, y-1, newclr);
	    insert (x, y-1, &last);
	}
	

	if (getpixel (x, y+1) == oldclr)
	{
	    putpixel (x, y+1, newclr);
	    insert (x, y+1, &last);
	}
	
	if (getpixel (x-1, y) == oldclr)
	{
	    putpixel (x-1, y, newclr);
	    insert (x-1, y, &last);
	}
	
	if (getpixel (x+1, y) == oldclr)
	{
	    putpixel (x+1, y, newclr);
	    insert (x+1, y, &last);
	}
	
	tmp = first;
	first = first->next;
	x = first->x;
	y = first->y;
	free (tmp);
    }
}

void insert (int x, int y, struct Node** last)
{
    struct Node* p;
    p = (struct Node*) malloc (sizeof (struct Node));
    if (p == NULL)
    {
	closegraph();
	fprintf (stderr, "\n insert: Out of memory.\n");
	exit (2);
    }
    
    p->x = x;
    p->y = y;
    p->next = NULL;
    (*last)->next = p;
    *last = (*last)->next;
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-fill-any-given-polygon-using-scan-line-area-filling-algorithm/">C Program to fill any given polygon using scan-line area filling algorithm</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/graphics/c-program-to-fill-any-given-polygon-using-scan-line-area-filling-algorithm/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>C Program to implement 3-D rotation with respect to x-axis, y-axis and z-axis</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-3-d-rotation-with-respect-to-x-axis-y-axis-and-z-axis/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-3-d-rotation-with-respect-to-x-axis-y-axis-and-z-axis/#respond</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Fri, 02 Oct 2009 10:32:20 +0000</pubDate>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[c graphics]]></category>
		<category><![CDATA[3-d rotation in c]]></category>
		<category><![CDATA[3d rotaion graphics]]></category>
		<category><![CDATA[model of a cube]]></category>
		<category><![CDATA[codes]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[download]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=839</guid>

					<description><![CDATA[<p>C Program to implement 3-D rotation with respect to x-axis, y-axis and z-axis (wire frame model of a cube). Use appropriate data structures to manipulate the wire frame model.</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-3-d-rotation-with-respect-to-x-axis-y-axis-and-z-axis/">C Program to implement 3-D rotation with respect to x-axis, y-axis and z-axis</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>C Program to implement 3-D rotation with respect to x-axis, y-axis and z-axis (wire frame model of a cube). Use appropriate data structures to manipulate the wire frame model.</p>
<pre lang="c" escaped="true" line="1">
#include <stdio.h>
#include <graphics.h>
#include <math.h>
#include <stdlib.h>
#include <dos.h>
#include <conio.h>

#define ORG -50

double face1[5][2] = {
			    { 250, 125 },
			    { 350, 125 },
			    { 350, 225 },
			    { 250, 225 },
			    { 250, 125 }
		           };

double face2[5][2] = {
			    { 250+ORG, 125-ORG },
			    { 350+ORG, 125-ORG },
			    { 350+ORG, 225-ORG },
			    { 250+ORG, 225-ORG },
			    { 250+ORG, 125-ORG }
		           };

double angle = 5.0 * M_PI / 180;
double midx1, midy1, midx2, midy2;

void rotate (void)
{
    int i;
    for (i=0; i<5; i++)
    {
	double xnew, ynew;

	xnew = midx1 + (face1[i][0] - midx1) * cos (angle) -
	       (face1[i][1] - midy1) * sin (angle);
	ynew = midy1 + (face1[i][0] - midx1) * sin (angle) +
		(face1[i][1] - midy1) * cos (angle);

	face1[i][0] = xnew;
	face1[i][1] = ynew;

	xnew = midx2 + (face2[i][0] - midx2) * cos (angle) -
		(face2[i][1] - midy2) * sin (angle);
	ynew = midy2 + (face2[i][0] - midx2) * sin (angle) +
		(face2[i][1] - midy2) * cos (angle);

	face2[i][0] = xnew;
	face2[i][1] = ynew;
    }

    cleardevice();

    for (i=0; i<4; i++)
    {
	setcolor(7);
	line (face1[i][0], face1[i][1], face1[i+1][0], face1[i+1][1]);
	setcolor(8);
	line (face2[i][0], face2[i][1], face2[i+1][0], face2[i+1][1]);
	setcolor(9);
	line (face1[i][0], face1[i][1], face2[i][0], face2[i][1]);
    }

    delay (125);
}

void main()
{
    int gd = DETECT, gm;

    midx1 = (face1[0][0] + face1[1][0]) / 2.0;
    midy1 = (face1[1][1] + face1[2][1]) / 2.0;
    midx2 = (face2[0][0] + face2[1][0]) / 2.0;
    midy2 = (face2[1][1] + face2[2][1]) / 2.0;

    initgraph (&#038;gd, &#038;gm, "..\\bgi");

    while (!kbhit())
	rotate();

    closegraph();
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-3-d-rotation-with-respect-to-x-axis-y-axis-and-z-axis/">C Program to implement 3-D rotation with respect to x-axis, y-axis and z-axis</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/graphics/c-program-to-implement-3-d-rotation-with-respect-to-x-axis-y-axis-and-z-axis/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>C Program to implement Bezier curves for a given set of control points.</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-bezier-curves-for-a-given-set-of-control-points/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-bezier-curves-for-a-given-set-of-control-points/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Fri, 02 Oct 2009 10:26:58 +0000</pubDate>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[c graphics]]></category>
		<category><![CDATA[bgi]]></category>
		<category><![CDATA[dos]]></category>
		<category><![CDATA[Bezier curves]]></category>
		<category><![CDATA[control points]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=835</guid>

					<description><![CDATA[<p>double xt = pow (1-t, 3) * x[0] + 3 * t * pow (1-t, 2) * x[1] +<br />
    3 * pow (t, 2) * (1-t) * x[2] + pow (t, 3) * x[3];</p>
<p>double yt = pow (1-t, 3) * y[0] + 3 * t * pow (1-t, 2) * y[1] +<br />
    3 * pow (t, 2) * (1-t) * y[2] + pow (t, 3) * y[3];</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-bezier-curves-for-a-given-set-of-control-points/">C Program to implement Bezier curves for a given set of control points.</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="c" escaped="true" line="1">
#include <stdio.h>
#include <stdlib.h>
#include <graphics.h>
#include <math.h>

void bezier (int x[4], int y[4])
{
    int gd = DETECT, gm;
    int i;
    double t;

    initgraph (&gd, &gm, "..\\bgi");

    for (t = 0.0; t < 1.0; t += 0.0005)
    {
	double xt = pow (1-t, 3) * x[0] + 3 * t * pow (1-t, 2) * x[1] +
		    3 * pow (t, 2) * (1-t) * x[2] + pow (t, 3) * x[3];

	double yt = pow (1-t, 3) * y[0] + 3 * t * pow (1-t, 2) * y[1] +
		    3 * pow (t, 2) * (1-t) * y[2] + pow (t, 3) * y[3];

	putpixel (xt, yt, WHITE);
    }

    for (i=0; i<4; i++)
	putpixel (x[i], y[i], YELLOW);

    getch();
    closegraph();
    return;
}

void main()
{
    int x[4], y[4];
    int i;

    printf ("Enter the x- and y-coordinates of the four control points.\n");
    for (i=0; i<4; i++)
	scanf ("%d%d", &#038;x[i], &#038;y[i]);

    bezier (x, y);
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-bezier-curves-for-a-given-set-of-control-points/">C Program to implement Bezier curves for a given set of control points.</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/graphics/c-program-to-implement-bezier-curves-for-a-given-set-of-control-points/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>C Program to implement the Cohen-Sutherland line-clipping algorithm.</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-the-cohen-sutherland-line-clipping-algorithm/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-the-cohen-sutherland-line-clipping-algorithm/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Fri, 02 Oct 2009 10:19:36 +0000</pubDate>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[c graphics]]></category>
		<category><![CDATA[rectangle functions]]></category>
		<category><![CDATA[line functions]]></category>
		<category><![CDATA[clipping]]></category>
		<category><![CDATA[line clipping]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=832</guid>

					<description><![CDATA[<p>C Program to implement the Cohen-Sutherland line-clipping algorithm. Make provision to specify the input line, window for clipping and view port for displaying the clipped image.  (Use built-in line and rectangle functions).</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-the-cohen-sutherland-line-clipping-algorithm/">C Program to implement the Cohen-Sutherland line-clipping algorithm.</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>C Program to implement the Cohen-Sutherland line-clipping algorithm. Make provision to specify the input line, window for clipping and view port for displaying the clipped image.  (Use built-in line and rectangle functions).</p>
<pre lang="c" escaped="true" line="1">
#include <stdio.h>
#include <stdlib.h>
#include <graphics.h>
#define MAX 20

enum { TOP = 0x1, BOTTOM = 0x2, RIGHT = 0x4, LEFT = 0x8 };

enum { FALSE, TRUE };
typedef unsigned int outcode;

outcode compute_outcode(int x, int y,
		int xmin, int ymin, int xmax, int ymax)
{
    outcode oc = 0;

    if (y > ymax)
	oc |= TOP;
    else if (y < ymin)
	oc |= BOTTOM;


    if (x > xmax)
	oc |= RIGHT;
    else if (x < xmin)
	oc |= LEFT;

    return oc;
}

void cohen_sutherland (double x1, double y1, double x2, double y2,
		double xmin, double ymin, double xmax, double ymax)
{
    int accept;
    int done;
    outcode outcode1, outcode2;

    accept = FALSE;
    done = FALSE;

    outcode1 = compute_outcode (x1, y1, xmin, ymin, xmax, ymax);
    outcode2 = compute_outcode (x2, y2, xmin, ymin, xmax, ymax);
    do
    {
	if (outcode1 == 0 &#038;&#038; outcode2 == 0)
	{
	    accept = TRUE;
	    done = TRUE;
	}
	else if (outcode1 &#038; outcode2)
	{
	    done = TRUE;
	}
	else
	{
	    double x, y;
	    int outcode_ex = outcode1 ? outcode1 : outcode2;
	    if (outcode_ex &#038; TOP)
	    {
		x = x1 + (x2 - x1) * (ymax - y1) / (y2 - y1);
		y = ymax;
	    }

	    else if (outcode_ex &#038; BOTTOM)
	    {
		x = x1 + (x2 - x1) * (ymin - y1) / (y2 - y1);
		y = ymin;
	    }
	    else if (outcode_ex &#038; RIGHT)
	    {
		y = y1 + (y2 - y1) * (xmax - x1) / (x2 - x1);
		x = xmax;
	    }
	    else
	    {
		y = y1 + (y2 - y1) * (xmin - x1) / (x2 - x1);
		x = xmin;
	    }
	    if (outcode_ex == outcode1)
	    {
		x1 = x;
		y1 = y;
		outcode1 = compute_outcode (x1, y1, xmin, ymin, xmax, ymax);
	    }
	    else
	    {
		x2 = x;
		y2 = y;
		outcode2 = compute_outcode (x2, y2, xmin, ymin, xmax, ymax);
	    }
	}
    } while (done == FALSE);

    if (accept == TRUE)
	line (x1, y1, x2, y2);
}



void main()
{
    int n;
    int i, j;
    int ln[MAX][4];
    int clip[4];
    int gd = DETECT, gm;

    printf ("Enter the number of lines to be clipped");
    scanf ("%d", &#038;n);

    printf ("Enter the x- and y-coordinates of the line-endpoints:\n");
    for (i=0; i<n; i++)
	for (j=0; j<4; j++)
	    scanf ("%d", &#038;ln[i][j]);

    printf ("Enter the x- and y-coordinates of the left-top and right-");
    printf ("bottom corners\nof the clip window:\n");
    for (i=0; i<4; i++)
	scanf ("%d", &#038;clip[i]);

    initgraph (&#038;gd, &#038;gm, "..//bgi");

    rectangle (clip[0], clip[1], clip[2], clip[3]);
    for (i=0; i<n; i++)
	line (ln[i][0], ln[i][1], ln[i][2], ln[i][3]);
    getch();
    cleardevice();
    rectangle (clip[0], clip[1], clip[2], clip[3]);
    for (i=0; i<n; i++)
    {
	cohen_sutherland (ln[i][0], ln[i][1], ln[i][2], ln[i][3],
	    clip[0], clip[1], clip[2], clip[3]);
	getch();
    }
    closegraph();
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-the-cohen-sutherland-line-clipping-algorithm/">C Program to implement the Cohen-Sutherland line-clipping algorithm.</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/graphics/c-program-to-implement-the-cohen-sutherland-line-clipping-algorithm/feed/</wfw:commentRss>
			<slash:comments>18</slash:comments>
		
		
			</item>
		<item>
		<title>C Program to draw a rectangle and perform the operations.</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-draw-a-rectangle-and-perform-the-operations/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-draw-a-rectangle-and-perform-the-operations/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Fri, 02 Oct 2009 10:11:58 +0000</pubDate>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[shear]]></category>
		<category><![CDATA[arbitory point]]></category>
		<category><![CDATA[Rotation of rectangle]]></category>
		<category><![CDATA[c graphics]]></category>
		<category><![CDATA[C Programs]]></category>
		<category><![CDATA[draw rectangle]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=828</guid>

					<description><![CDATA[<p>C Program to draw a rectangle and perform the following operations.<br />
	a. Rotation about the origin followed by translation.<br />
	b. Rotation about an arbitrary point.<br />
	c. Apply X shear and Y shear on the rectangle.</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-draw-a-rectangle-and-perform-the-operations/">C Program to draw a rectangle and perform the operations.</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>C Program to draw a rectangle and perform the following operations.<br />
	a. Rotation about the origin followed by translation.<br />
	b. Rotation about an arbitrary point.<br />
	c. Apply X shear and Y shear on the rectangle.</p>
<pre lang="c" escaped="true" line="1">
#include <stdio.h>
#include <graphics.h>
#include <stdlib.h>
#include <math.h>

void draw (int r[][2])
{
    int i;
    setlinestyle (DOTTED_LINE, 0, 1);
    line (320, 0, 320, 480);
    line (0, 240, 640, 240);

    setlinestyle (SOLID_LINE, 0, 1);
    line (320+r[0][0], 240-r[0][1], 320+r[1][0], 240-r[1][1]);
    line (320+r[0][0], 240-r[0][1], 320+r[3][0], 240-r[3][1]);
    line (320+r[1][0], 240-r[1][1], 320+r[2][0], 240-r[2][1]);
    line (320+r[2][0], 240-r[2][1], 320+r[3][0], 240-r[3][1]);
}

void reset (int r[][2])
{
    int i;
    int val[4][2] = {
			{ 0, 0 },{ 100, 0 },{ 100, 50 },{ 0, 50 }
		    };
	for (i=0; i<4; i++)
    {
	r[i][0] = val[i][0];
	r[i][1] = val[i][1];
    }
}

void rotate (int r[][2], int angle)
{
    int i;
    double ang_rad = (angle * M_PI) / 180;
    for (i=0; i<4; i++)
    {
	double xnew, ynew;
	xnew = r[i][0] * cos (ang_rad) - r[i][1] * sin (ang_rad);
	ynew = r[i][0] * sin (ang_rad) + r[i][1] * cos (ang_rad);
	r[i][0] = xnew;
	r[i][1] = ynew;
    }
}

void shear (int r[][2], int sx, int sy)
{
    int i;
    for (i=0; i<4; i++)
    {
	int xnew, ynew;
	xnew = r[i][0] + r[i][1] * sx;
	ynew = r[i][1] + r[i][0] * sy;
	r[i][0] = xnew;
	r[i][1] = ynew;
    }
}

void translate (int r[][2], int dx, int dy)
{
    int i;
    for (i=0; i<4; i++)
    {
	r[i][0] += dx;
	r[i][1] += dy;
    }
}

void ini()
{
	int gd=DETECT,gm;
	initgraph(&#038;gd,&#038;gm,"..//bgi");
}
void main()
{

	int r[4][2],angle,dx,dy,x, y,choice;

	do
	{
		clrscr();
		printf("1.Rotation about the origin followed by translation\n");
		printf("2.Rotation about an arbitrary point\n");
		printf("3.Shear about the origin\n");
		printf("4.Exit\n\n");
		printf("Enter your choice: ");
		scanf("%d",&#038;choice);
		switch(choice)
		{
			case 1: printf("Enter the rotation angle: ");
				scanf("%d", &#038;angle);
				printf("Enter the x- and y-coordinates for translation: ");
				scanf("%d%d",&#038;dx,&#038;dy);
				ini();
				cleardevice();
				reset(r);
				draw(r);getch();
				rotate(r, angle);
				cleardevice();
				draw(r);getch();
				translate(r,dx,dy);
				cleardevice();
				draw(r);getch();
				closegraph();
				break;
			case 2: printf("Enter the rotation angle: ");
				scanf("%d",&#038;angle);
				printf("Enter the x- and y-coordinates of the point: ");
				scanf("%d%d",&#038;x,&#038;y);
				ini();
				cleardevice();
				reset(r);
				translate(r,x,y);
				draw(r);
				putpixel(320+x,240-y,WHITE);
				getch();
				translate(r,-x,-y);
				draw(r);getch();
				rotate(r,angle);
				draw(r);getch();
				translate(r,x,y);
				cleardevice();
				draw(r);
				putpixel(320+x,240-y,WHITE);
				getch();
				closegraph();
				break;
			case 3: printf("Enter the x- and y-shears: ");
				scanf("%d%d",&#038;x,&#038;y);
				ini();
				reset(r);
				draw(r);getch();
				shear(r, x, y);
				cleardevice();
				draw (r);getch();
				closegraph();
				break;
			case 4: closegraph();
		}
	}while(choice!=4);
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-draw-a-rectangle-and-perform-the-operations/">C Program to draw a rectangle and perform the operations.</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/graphics/c-program-to-draw-a-rectangle-and-perform-the-operations/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>C Program to display a line graph using midpoint line algorithm.</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-display-a-line-graph-using-midpoint-line-algorithm/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-display-a-line-graph-using-midpoint-line-algorithm/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Fri, 02 Oct 2009 10:07:21 +0000</pubDate>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[c graphics]]></category>
		<category><![CDATA[Software Programs]]></category>
		<category><![CDATA[line graph]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=823</guid>

					<description><![CDATA[<p>Program to display a line graph using midpoint line algorithm. The input to the program is a set of data corresponding to the X and Y-axes. Data parts are to be displayed as asterisk (*) according to the input specification.</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-display-a-line-graph-using-midpoint-line-algorithm/">C Program to display a line graph using midpoint line algorithm.</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Program to display a line graph using midpoint line algorithm. The input to the program is a set of data corresponding to the X and Y-axes. Data parts are to be displayed as asterisk (*) according to the input specification.</p>
<pre lang="c" escaped="true" line="1">
#include<stdio.h>
#include<graphics.h>
#include<stdlib.h>
#include<conio.h>

#define MAX 20

void swap(int* a,int* b)
{
	int t=*a;
	*a=*b;
	*b=t;
}

void midpointline(int x1,int y1,int x2,int y2)
{
	int dx,dy,d,incry,incre,incrne,slopegt1=0;
	dx=abs(x1-x2);dy=abs(y1-y2);
	if(dy>dx)
	{
		swap(&x1,&y1);
		swap(&x2,&y2);
		swap(&dx,&dy);
		slopegt1=1;
	}
	if(x1>x2)
	{
		swap(&x1,&x2);
		swap(&y1,&y2);
	}
	if(y1>y2)
		incry=-1;
	else
		incry=1;
	d=2*dy-dx;
	incre=2*dy;
	incrne=2*(dy-dx);
	while(x1<x2)
	{
		if(d<=0)
			d+=incre;
		else
		{
			d+=incrne;
			y1+=incry;
		}
		x1++;
		if(slopegt1)
			putpixel(y1,x1,WHITE);
		else
			putpixel(x1,y1,WHITE);
	}
}

void main()
{
	int n,i;
	int pt[MAX][2];
	int gd=DETECT,gm;

	printf("Enter the number of points:");
	scanf("%d",&#038;n);

	printf("Enter the x and y coordinates:");
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&#038;pt[i][0],&#038;pt[i][1]);
		pt[i][1]=480 - pt[i][1];
	}

	initgraph(&#038;gd,&#038;gm,"..\\bgi");

	line(1,0,1,480);		// X - Axis
	line(0,479,639,479);		// Y - Axis

	outtextxy(pt[0][0]-2,pt[0][1]-3,"*");

	for(i=0;i<n-1;i++)
	{
		midpointline(pt[i][0],pt[i][1],pt[i+1][0],pt[i+1][1]);
		outtextxy(pt[i+1][0]-2,pt[i+1][1]-3,"*");
	}
	getch();
	closegraph();
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-display-a-line-graph-using-midpoint-line-algorithm/">C Program to display a line graph using midpoint line algorithm.</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/graphics/c-program-to-display-a-line-graph-using-midpoint-line-algorithm/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>C Program to for Midpoint Line algorithm</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-for-midpoint-line-algorithm/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-for-midpoint-line-algorithm/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Fri, 02 Oct 2009 09:51:23 +0000</pubDate>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[programs]]></category>
		<category><![CDATA[c graphics]]></category>
		<category><![CDATA[line]]></category>
		<category><![CDATA[sourcecodes]]></category>
		<category><![CDATA[Midpoint]]></category>
		<category><![CDATA[graphics.h]]></category>
		<category><![CDATA[swap]]></category>
		<category><![CDATA[polyline]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=820</guid>

					<description><![CDATA[<p>Program to implement the Midpoint Line algorithm to generate a line of given slope and thickness. Implement the polyline (many lines) command using this algorithm as a routine that display a set of straight lines between N input points. For n=1 the routine displays a single point.</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-for-midpoint-line-algorithm/">C Program to for Midpoint Line algorithm</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Program to implement the Midpoint Line algorithm to generate a line of given slope and thickness. Implement the polyline (many lines) command using this algorithm as a routine that display a set of straight lines between N input points. For n=1 the routine displays a single point.</p>
<pre lang="c" escaped="true" line="1">
#include<stdio.h>
#include<stdlib.h>
#include<graphics.h>
#include<math.h>
#include<conio.h>
#define MAX 10

void swap(int* a,int* b)
{
	int t=*a;
	*a=*b;
	*b=t;
}

void midpointline(int x1,int y1,int x2,int y2)
{
	int dx,dy,d,incry,incre,incrne,slopegt1=0;
	dx=abs(x1-x2);dy=abs(y1-y2);
	if(dy>dx)
	{
		swap(&x1,&y1);
		swap(&x2,&y2);
		swap(&dx,&dy);
		slopegt1=1;
	}
	if(x1>x2)
	{
		swap(&x1,&x2);
		swap(&y1,&y2);
	}
	if(y1>y2)
		incry=-1;
	else
		incry=1;
	d=2*dy-dx;
	incre=2*dy;
	incrne=2*(dy-dx);
	while(x1<x2)
	{
		if(d<=0)
			d+=incre;
		else
		{
			d+=incrne;
			y1+=incry;
		}
		x1++;
		if(slopegt1)
			putpixel(y1,x1,WHITE);
		else
			putpixel(x1,y1,WHITE);
	}
}

void poly_line(int x[MAX],int y[MAX],int n,int thick)
{
	int i=0,j=0;
	for(i=0;i<n-1;i++)
		for(j=0;j<thick;j++)
			midpointline(x[i]+j,y[i],x[i+1]+j,y[i+1]);
}

int main()
{
	int gd=DETECT,gm,thick;
	int x[MAX],y[MAX],n,i;
	printf("Number of points:");
	scanf("%d",&#038;n);

	printf("Enter x and y co-ord:");
	for(i=0;i<n;i++)
		scanf("%d %d",&#038;x[i],&#038;y[i]);
	initgraph(&#038;gd,&#038;gm,"..\\bgi");
	if(n==1)
	{
		for(i=0;i<n;i++)
			putpixel(x[i],y[i],YELLOW);
	}
	else
	{
		poly_line(x,y,n,1);
	}
	getch();
	closegraph();
	return 0;
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-for-midpoint-line-algorithm/">C Program to for Midpoint Line algorithm</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/graphics/c-program-to-for-midpoint-line-algorithm/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>C program to for Moving Car</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-for-moving-car/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-for-moving-car/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Fri, 02 Oct 2009 09:17:14 +0000</pubDate>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[Source Codes]]></category>
		<category><![CDATA[c graphics]]></category>
		<category><![CDATA[programs]]></category>
		<category><![CDATA[cleardevice]]></category>
		<category><![CDATA[moving graphics]]></category>
		<category><![CDATA[closegraph]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=818</guid>

					<description><![CDATA[<p>line(80+i,300,90+i,270);<br />
line(90+i,270,120+i,270);<br />
line(120+i,270,160+i,240);<br />
line(160+i,240,230+i,240);<br />
line(230+i,240,275+i,270);</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-for-moving-car/">C program to for Moving Car</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="c" escaped="true" line="1">
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
#include<graphics.h>

void main()
{
	int gd=DETECT,gm;
	int i=0,m=0;
	initgraph(&gd,&gm,"..\\bgi");
	while(!kbhit())
	{
		cleardevice();
		i++;
		if(i>getmaxx())
			i-=670;
		line(80+i,300,90+i,270);
		line(90+i,270,120+i,270);
		line(120+i,270,160+i,240);
		line(160+i,240,230+i,240);
		line(230+i,240,275+i,270);
		line(275+i,270,310+i,270);
		line(310+i,270,335+i,290);
		line(335+i,290,335+i,300);
		line(255+i,300,335+i,300);
		line(180+i,300,210+i,300);
		line(80+i,300,135+i,300);
		arc(232+i,300,0,180,23);
		arc(157+i,300,0,180,23);
		circle(232+i,300,18);
		circle(157+i,300,18);
		pieslice(232+i,300,0+m,90+m,18);
		pieslice(232+i,300,180+m,270+m,18);
		pieslice(157+i,300,0+m,90+m,18);
		pieslice(157+i,300,180+m,270+m,18);
		if(m<-360)
			m=90;
		m-=3;	
	delay(5);
	}
	getch();
	closegraph();
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-for-moving-car/">C program to for Moving Car</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/graphics/c-program-to-for-moving-car/feed/</wfw:commentRss>
			<slash:comments>21</slash:comments>
		
		
			</item>
		<item>
		<title>C program to for Rotation of wheel</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-for-rotation-of-wheel/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-for-rotation-of-wheel/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Fri, 02 Oct 2009 09:01:17 +0000</pubDate>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[c graphics]]></category>
		<category><![CDATA[programs]]></category>
		<category><![CDATA[circle rotation]]></category>
		<category><![CDATA[wheel graphics]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=816</guid>

					<description><![CDATA[<p>theta=M_PI*angle/180;<br />
x[i]=xc+r*cos(theta);<br />
y[i]=yc+r*sin(theta);<br />
angle+=20;<br />
line(xc,yc,x[i],y[i]);</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-for-rotation-of-wheel/">C program to for Rotation of wheel</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="c" escaped="true" line="1">
#include<stdio.h>
#include<graphics.h>
#include<math.h>
#include<conio.h>
#include<dos.h>

int xc=50,yc=200,r=35;
int x[15],y[15];
void drawcircles()
{
	setcolor(YELLOW);
	circle(xc,yc,r);
	circle(xc,yc,r+5);
}
void main()
{
	double angle=0,theta;
	int i,a;
	int gd=DETECT,gm;
	initgraph(&gd,&gm,"..\\bgi");
	a=xc+r;
	while(!kbhit())
	{
		while(a<=630)
		{
			theta=M_PI*angle/180;
			cleardevice();
			drawcircles();
			for(i=0;i<18;i++)
			{
				theta=M_PI*angle/180;
				x[i]=xc+r*cos(theta);
				y[i]=yc+r*sin(theta);
				angle+=20;
				line(xc,yc,x[i],y[i]);
			}
			angle+=2; xc+=2; a=xc+r;
			delay(50);
		}
		xc=50;	r=35; a=xc+r;
	}
	getch();
	closegraph();
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-for-rotation-of-wheel/">C program to for Rotation of wheel</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/graphics/c-program-to-for-rotation-of-wheel/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
