Вы находитесь на странице: 1из 9

Bresenham's Line Drawing Algorithm by Rekha Ram Ch... http://www.planet-source-code.com/vb/scripts/ShowCode...

Code: 1,325,050. lines


Jobs: 253. postings

C/ C++ Stats:

How to support the site

Sponsored by:

.Net (VB and C#)


PHP
Javascript
Java
C/C++
SQL
Perl
ASP classic
VB classic
Delphi
Cold Fusion

Code/Articles
Newest
Browse categories
Search
-----------------------
Upload code / articles
Open letter from moderators
-----------------------
Articles & tutorials
Recommended reading
Top Code
Coding contest
Coding contest leader board
Coding contest 'All-Time Hall of Fame'
-----------------------
Code of the day newsletter
Community
Ask a pro discussion forum
Games
Code of the day newsletter
Jobs
Search for a job

1 of 9 Tuesday 09 October 2012 05:10 AM


Bresenham's Line Drawing Algorithm by Rekha Ram Ch... http://www.planet-source-code.com/vb/scripts/ShowCode...

Post a job
Other
My profile
How to link to us
Awards/Reviews/Raves!
Advertising/Media kit
Feedback
About the site
Goto…
C/ C++ home
Site home
Other sites

Important alert: (current site time 10/8/2012 7:35:28 PM EDT)


Do you want to see new Planet Source CD's? Click here to let us know what you think!

Print
Bresenham's Line Drawing Algorithm
Email
Submitted on: 9/6/2012 2:57:42 PM
By: Rekha Ram Chaudhary
Level: Beginner
User Rating: Unrated
Compatibility:C

Users have accessed this code 849 times.

(About the author)

This is a simple program to implement Bresenham's Line Drawing Algorithm in C program.

2 of 9 Tuesday 09 October 2012 05:10 AM


Bresenham's Line Drawing Algorithm by Rekha Ram Ch... http://www.planet-source-code.com/vb/scripts/ShowCode...

code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

Terms of Agreement:
By using this code, you agree to the following terms...

1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages
that allow it) freely and with no charge.
2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so
is a violation of copyright laws.
3. You may link to this code from another website, but ONLY if it is not wrapped in a frame.
4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

//**************************************
// Name: Bresenham's Line Drawing Algorithm
// Description:This is a simple program to implement Bresenham's Line Drawing Algorithm in
// By: Rekha Ram Chaudhary
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Sourc

#include "stdio.h"
#include "conio.h"
#include "math.h"
#include "graphics.h"
main()
{
int gd=DETECT,gm;

3 of 9 Tuesday 09 October 2012 05:10 AM


Bresenham's Line Drawing Algorithm by Rekha Ram Ch... http://www.planet-source-code.com/vb/scripts/ShowCode...

int xa,xb,ya,yb;
int dx,dy,x,y,xend,p;
initgraph(&gd,&gm,"c:\\tc\\bgi");
printf("Enter The Two Left Endpoints(xa,ya):\n");
scanf("%d%d",&xa,&ya);
printf("Enter The Two Right Endpoints(xb,yb):\n");
scanf("%d%d",&xb,&yb);
dx=abs(xa-xb);
dy=abs(ya-yb);
p=2*dy-dx;
if(xa>xb)
{
x=xb;
y=yb;
xend=xa;
}
else
{
x=xa;
y=ya;
xend=xb;
}
putpixel(x,y,6);
while(x<xend)
{
x=x+1;
if(p<0)
{
p=p+2*dy;
}
else
{
y=y+1;
p =p+2*(dy-dx);
}
putpixel(x,y,6);
}
getch();
return(0);
}

Is this code not quite what you want? Click here for custom coding.

4 of 9 Tuesday 09 October 2012 05:10 AM


Bresenham's Line Drawing Algorithm by Rekha Ram Ch... http://www.planet-source-code.com/vb/scripts/ShowCode...

Other 9 submission(s) by this author

Report Bad Submission


Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Report it!

Your Vote!

What do you think of this code(in the Beginner category)?


(The code with your highest vote will win this month's coding contest!)

Excellent Good Average Below Average Poor Rate It! See Voting Log. If this
code was not quite what you wanted, then click here for custom coding.

Other User Comments

There are no comments on this submission.

5 of 9 Tuesday 09 October 2012 05:10 AM


Bresenham's Line Drawing Algorithm by Rekha Ram Ch... http://www.planet-source-code.com/vb/scripts/ShowCode...

Download Google Chrome


Searching is fast and easy with Google's web
browser.
www.Google.com/Chrome

Add Your Feedback!

Note:Not only will your feedback be posted, but an email will be sent to the code's author from the email
account you registered on the site, so you can correspond directly.

NOTICE: The author of this code has been kind enough to share it with you. If you have a
criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.

To post feedback, first please login.

Quick search for

C / C++ Search Term… Search Term…


Search

Login

6 of 9 Tuesday 09 October 2012 05:10 AM


Bresenham's Line Drawing Algorithm by Rekha Ram Ch... http://www.planet-source-code.com/vb/scripts/ShowCode...

Latest postings for C/ C++.

Matrix
Calculations

By Kishan Singh
on 10/2

Scientific
Calculator 001

By Kishan Singh
Clickon
here to put this ticker
10/2
on your site!

Add to Active Desktop


EasyNumberFunct
Add this
ions ticker
V_1.0 to your desktop!

Daily
ByCode Email
Dasttann777
on 10/2
Click here to join the
'Code of the Day' mailing list!

auto hide start

ThisBySite
sam on
lee CD
on
9/26

7 of 9 Tuesday 09 October 2012 05:10 AM


Bresenham's Line Drawing Algorithm by Rekha Ram Ch... http://www.planet-source-code.com/vb/scripts/ShowCode...

Over 7,000 submissions on a super fast CD!

Get Paid To Code

Now taking registrations on Rent a Coder!

Open letter from moderators


About the site
Feedback
Link to the Site
Awards
Advertising
Privacy

Code/Articles

Newest
Browse categories
Search
Upload code / articles
Open letter from moderators
Articles & tutorials
Recommended reading

Top Code

Coding contest
Coding contest leader board

8 of 9 Tuesday 09 October 2012 05:10 AM


Bresenham's Line Drawing Algorithm by Rekha Ram Ch... http://www.planet-source-code.com/vb/scripts/ShowCode...

Coding contest 'All-Time Hall of Fame'


Code of the day newsletter

Community

Ask a pro discussion forum


Games
Code of the day newsletter

Jobs

Search for a job


Post a job

Other

My profile
How to link to us
Awards/Reviews/Raves!
Advertising/Media kit
Feedback
About the site

Goto…

C/ C++ home
Site home
Other sites

Copyright© 1997-2012 by Exhedra Solutions, Inc. All Rights Reserved.

By using this site you agree to its Terms and Conditions. Planet Source Code™ and the
phrase "Dream It. Code It"™ are trademarks of Exhedra Solutions, Inc.

9 of 9 Tuesday 09 October 2012 05:10 AM

Вам также может понравиться