News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Line-drawing routine

Started by NoCforMe, May 22, 2024, 02:08:47 PM

Previous topic - Next topic

sinsi

With 320x200 resolution and 256 colours any antialiasing would be a waste of time  :biggrin:

FORTRANS

Hi,

Quote from: daydreamer on May 29, 2024, 04:07:34 PMAnyone already have antialiased line code ?

   I have used Michael Abrash's Wu antialiased line drawing
code.  I posted some results inhttps://masm32.com/board/index.php?topic=5469.msg58613#msg58613.

Steve

NoCforMe

Steve, saw the images; interesting. Did you post code for that? or if not, can you? I'm curious to see how that antialising works.
Assembly language programming should be fun. That's why I do it.

FORTRANS

Hi,

Quote from: NoCforMe on May 30, 2024, 09:42:36 AMSteve, saw the images; interesting.

   Thanks.

QuoteDid you post code for that?

   Nobody replied to that post, so I assume not.

Quoteor if not, can you? I'm curious to see how that antialising works

   Okay.  The code was copied from a PDF using OCR and editing.
References should be mentioned both in the code and that other
ZIP.  Some errors may exist and I altered some comments.  You
should read the original text by Abrash.  If a moderator is
worried that it's not original code by me: croak it.

   I am also assuming you are not concerned about the gamma
correction mentioned in the prior post.

Cheers,

Steve N.

NoCforMe

Quote
QuoteDid you post code for that?
Nobody replied to that post, so I assume not.
Quoteor if not, can you? I'm curious to see how that antialising works
Okay.  The code was copied from a PDF using OCR and editing.
References should be mentioned both in the code and that other
ZIP.  Some errors may exist and I altered some comments.  You
should read the original text by Abrash.
I did find this explanation of antialiasing online. It uses the midline algorithm instead of Bresenham's, but other than that will work.
Unfortunately, it's written by a mathematician, not a programmer, and is therefore full of a certain amount of hand-waving, which isn't helpful. Plus the nomenclature (not all of it explained) makes my head hurt.
Basically you find the distance (an error term) between the actual line being drawn (pixels) and the theoretical line if you weren't drawing pixels, then shade the pixels according to the distance from the virtual line. That much I understand.
I wish there were some common-sense, nuts-and-bolts explanation of antialiasing. Maybe in that book you mentioned (but I looked that up: do you realize that copies of that book are selling starting at $182 and go up to $980? It's ridiculous. Check it out on bookfinder.com, the best resource for locating stuff printed on dead trees.)
Assembly language programming should be fun. That's why I do it.

tda0626

Thought about trying my hand at the pseudo code here of Wu's algorithm, see link below. It looks doable and doesn't include any fancy math speak.

Wu's AA Line


Tim

NoCforMe

#21
Not a fan of Wikipedia (in fact, I pretty much hate it), but I'll admit I've gotten working pseudocode from them before.

That example seems to use floating-point math, so probably not usable.
Assembly language programming should be fun. That's why I do it.

FORTRANS

Hi,

   I got a PDF of the book from the internet way back when.
It is a scanned version of the book and has a rough look to
it.  And I just looked for it and did not find it.  Drat.
I did find a set of text programs in GRAPHPRO.LZH.  I will
try to find my copy of the book and see if I can get a better
name to search for it.

  Google gets a lot of hits for the PDF.  I have not looked
at those though.  Oh well.

Regards,

Steve N.

FORTRANS

Hi,

   This link has the same sort of files that I downloaded a
long while back.  It is not where I got them.  And the file
dates are wrong.

https://medusa.teodesian.net/docs/computing/gpbb/

Regards,

Steve

NoCforMe

#24
I found the two relevant chapters in that repository:
Bresenham is Fast, and Fast is Good
Wu'ed in Haste; Fried, Stewed at Leisure

@Steve: Just want to let you know that these are exactly the kind of explanations I was looking for. Clear, cogent, well-written, explaining the concept first (with pictures!), then implementation details with both C and assembly-language examples. Excellent stuff!
Assembly language programming should be fun. That's why I do it.