delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/28/20:13:26

From: Damian Yerrick <DELCAPSyerricde AT pineight DOT 8mSOFTWARE DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Needing help testing linedrawing function
Organization: Pin Eight Software <http://yerricde.tripod.com/binaries/>
Message-ID: <Y80YODZya2yKgEUy6E+0EcqUHLTx@4ax.com>
References: <7vahjf$81u$1 AT tron DOT sci DOT fi>
X-Newsreader: Forte Agent 1.6/32.525
MIME-Version: 1.0
Lines: 54
X-Trace: +4awYQyVUpuTH7ilwct28wsyH3nXeA6Zbw8gRCY6wtYYbvjHAdITtsbSteUGDcXpCKdQcyWZCC+f!REUfag81P7MANDHYoBekoIQLcMlRJkoFO63QWyncc2oVDb0um832a7vMh6ZOTkbDXA==
X-Complaints-To: abuse AT gte DOT net
X-Abuse-Info: Please be sure to forward a copy of ALL headers
X-Abuse-Info: Otherwise we will be unable to process your complaint properly
NNTP-Posting-Date: Thu, 28 Oct 1999 22:38:55 GMT
Distribution: world
Date: Thu, 28 Oct 1999 22:38:55 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Fri, 29 Oct 1999 01:14:20 +0300,
"stefan fröberg" <traveler AT netti DOT fi> wrote:

> Hi !
> 
> This is my try to make reasonable fast linedrawing algorithm.
> What I want to know is how does it compare versus Bresenham's drawing
> algorithm.
> I don't know how it is coded, so if somebody who knows it would be so nice
> and do the testing for me ?
> 
> This stuff uses the '_farsetsel(_dos_ds)' and the
> '_farnspokeb(0xA0000+(y*320)+x,color)' to plot the pixels.
> 
> The example code is quite large so I add it with this message.
> 
> For any bug fixes, suggestions, performance improvements, etc.,
> send e-mail to traveler AT netti DOT fi

Posted and mailed.

Somewhat off-topic, but I'll answer it anyway. Next time, please
consider an algorithms group.

Bresenham in a nutshell (vastly oversimplified):

To draw a line from (x1, y1) to (x2, y2):

First special case out orthogonal lines.
  If x1 = x2 then draw a vertical line.
  If y1 = y2 then draw a horizontal line.

Essentially, you keep an "error term" telling how far off the line is
from the true line. The error term is initially set to half the
"width" (x2 - x1) of the line.

For each x pixel, add the "height" of the line (y2 - y1) to the error
term. If the error term >= the width of the line, subtract the width
from the error term and increment the current y position.

Play with this description. If you have any questions about Bresenham,
there are algorithms newsgroups such as comp.graphics.algorithms (is
c.g.a a pun on color graphics adapter?).


=== Tongue in cheek disclaimer follows ===
WARNING: All algorithms invented in the last 20 years are still
patented. There are corporations that exist only to sue someone who
infringes on a little-known patent. There is a company who has a
patent on spreadsheets.

--
Damian Yerrick
Visit my web site: http://yerricde.spedia.net/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019