www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/28/21:35:22

Message-ID: <00db01bdeb4a$1cec5700$366195cc@uic>
From: "Andrew Deren" <aderen AT interaccess DOT com>
To: "Jimmy" <jimmyml AT hotmail DOT com>, <djgpp AT delorie DOT com>
Subject: Re: Directional do_line
Date: Mon, 28 Sep 1998 20:40:16 -0500

-----Original Message-----
From: Jimmy <jimmyml AT hotmail DOT com>
Newsgroups: comp.os.msdos.djgpp
To: djgpp AT delorie DOT com <djgpp AT delorie DOT com>
Date: Monday, September 28, 1998 11:40 AM
Subject: Directional do_line


>I'm trying to use the allegro function do_line to calculate a path for a
>tank, but I've noticed that it doesn't go from (x1,y1) to (x2,y2), it
>starts at the point which has the lower x coordinate first.  Now, I
>could use this function and reverse the coordinates I get from do_line,
>but that would waste time.  Does anybody have a do_line function that
>draws a line between two points that you can pick the direction of the
>drawn line (eg. (x1,y1) -> (x2,y2))  TIA.
>James Larson
>jimmyml AT hotmail DOT com
>
The reason allegro reverses the coordinates is so that less cases are
handled,
by reversing you have only 4 cases to handle.
You can write your own line scan-conversion algorithm that handles all 8
cases
and while scan-converting store the results. The best place to look at is:
"Michael Abrash's Graphics Programming Black Book" which has an example of
Bresenhams line
drawin algorithm or if you want to know how it was derived: "computer
graphics: principles and Practice"
by Foley, van Dam, Feiner and Hughes.
I don't really know how allegro does it, but probably it's assembly code so
using do_line and
reversing the coordinates afterwards should be fast enough.
>


- Raw text -


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