Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] anti-aliased lines

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Nov 2009 20:31 Edited at: 23rd Nov 2009 22:53
A problem with DB's line command is the jagged edges. I wrote a function which used Bresenham's algorithm to draw a line so I could write it to a memblock, but this algorithm also had the problem of jagged edges. I came across Xiaolin Wu's algorithm, which uses antialiasing. Below is a picture comparing the 3 different lines.







> SELECT * FROM users WHERE clue > 0
> 0 rows returned

Attachments

Login to view attachments
GIDustin
15
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 22nd Nov 2009 23:16 Edited at: 24th Nov 2009 14:43
Wow, That looks really nice, however you are using DBP commands so it is a tad slow...

I have modified it to use Cloggy's D3D_Func commands as well as accept a color instead of just white. REQUIRES: D3D_Func,MatrixUtils_23. It speeds up the function from 4318ns to 736ns.

This has been added to my 2D command library. Thanks!



Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 23rd Nov 2009 07:54
Good to know about the speed increase. I don't use either of those libraries and I left my example with a white line because I knew adding real alpha with DBP commands would've slowed it down a lot. And as you've shown, adapting the existing concept was simple.

I'll probably try to see if I can use this technique with circles next then rounded boxes.


> SELECT * FROM users WHERE clue > 0
> 0 rows returned

Login to post a reply

Server time is: 2024-04-26 08:41:43
Your offset time is: 2024-04-26 08:41:43