<?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>Midpoint | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/midpoint/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Fri, 02 Oct 2009 09:51:23 +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 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[c graphics]]></category>
		<category><![CDATA[line]]></category>
		<category><![CDATA[programs]]></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>
	</channel>
</rss>
