### Author Topic: Have somebody implemented thick line algorithm?  (Read 2455 times)

#### Siekmanski

• Member
• Posts: 1803
##### Re: Have somebody implemented thick line algorithm?
« Reply #15 on: July 06, 2018, 08:58:07 PM »
Hi HSE,

Just my thoughts,

If you want to calculate a thick line, you could use the bresenham algorithm to draw a line pixel per pixel.
Draw more parallel next to each other to get a thicker line, each color a bit darker to get some antialiasing.

Or, use a texture quad with an antialiased circle or other pattern in it.
Then calculate the angle of the line, rotate the 4 quad coordinates and stretch it along the length of the line.
So that the thickness of the line is equal at any angle of the line.

Or, use the helper libraries from OpenGL, DirectX or the slow GDIplus functions.

The fastest but not the easiest way is, write a pixelshader antialiased line routine.

Here is a pixelshader antialiased line example from Inigo Quilez,
Creative coders use backward thinking techniques as a strategy.

#### HSE

• Member
• Posts: 984
• <AMD>< 7-32>
##### Re: Have somebody implemented thick line algorithm?
« Reply #16 on: July 07, 2018, 12:28:36 AM »
Thanks Siekmanski!

Without rotation nor antialiasing I have a very nice "Gut" effect

#### Siekmanski

• Member
• Posts: 1803
##### Re: Have somebody implemented thick line algorithm?
« Reply #17 on: July 07, 2018, 03:46:11 AM »
Creative coders use backward thinking techniques as a strategy.

#### HSE

• Member
• Posts: 984
• <AMD>< 7-32>
##### Re: Have somebody implemented thick line algorithm?
« Reply #18 on: July 07, 2018, 09:47:45 AM »
Here is Biterider idea. A lot simpler than what I was thinking.

Drawing a complete line 1000 times take:

GDI+    10500ms
GDI        1550ms
bigpixel   1010ms
pipeline    500ms

Of course they are different things, but comparisons are interesting.

#### HSE

• Member
• Posts: 984
• <AMD>< 7-32>
##### Re: Have somebody implemented thick line algorithm?
« Reply #19 on: July 08, 2018, 05:52:59 AM »
After some hours (trying to remember trigonometry )

Better now but 1000 complete lines take 1420ms 810ms (Sorry, I forget part of color calculation inside loops).  It's similar to big pixel  (now only points corresponding to parallel lines like Biterider idea) that is taking 478ms.

I think that because of dark margin antialiasing is unnecesary with a black background.

Thanks. Regards
« Last Edit: July 09, 2018, 03:11:12 AM by HSE »

#### daydreamer

• Member
• Posts: 741
• watch Chebyshev on the backside of the Moon
##### Re: Have somebody implemented thick line algorithm?
« Reply #20 on: August 19, 2018, 12:21:08 AM »
wonder how it looks with dx9 line or poly used as line with fullfledged hardware antialias filter?

Fanatics of DirectX assume that everybody know something that I don't know.

I found examples to draw a detailed tiger, planets in movement... but none to draw only a line
I didnt tell you because I am a dx fanatic,I told you because I want to help you and other members getting all alternatives to choose from otherwise you dont get the whole Picture
dx9 drawprimitive you see mostly TRIANGLELIST,TRIANGLESTRIP, less known is TRIANGLEFAN
http://zophusx.byethost11.com/tutorial.php?lan=dx9&num=10&i=1

actually wanted to ask question on whats smallest line algo?fpu or cpu drawing to a backbuffer I mean?
one initial fdiv smallest/biggest distance and fadd that and fadd 1 for each pixel in a loop?
same with fixed Point and cpu?but that maybe requires additional code with many bitshifting?

Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*

#### HSE

• Member
• Posts: 984
• <AMD>< 7-32>
##### Re: Have somebody implemented thick line algorithm?
« Reply #21 on: August 19, 2018, 02:37:01 AM »
I didnt tell you because I am a dx fanatic
Don't worry, the writer of that article also is a fanatic.

Apparently the "line" is only one code line.

If You know were to put that line, fantastic

Nowhere there is a working full program source code to draw a simple line. There is tutorials  with everything you need to draw a planetary system in movement or things so complex like that.

It's very interesting and perhaps some day I will study those tutorials. But now I'm not going to read 11 tutorials to draw a line

actually wanted to ask question on whats...

My english is a little limited (is what in this forum is know as pseudo-english). I really don't understand what you ask. Try to make complete questions,  different question in different lines, and capital letters sometimes are usefull