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

HSE

  • Member
  • ****
  • Posts: 807
  • <AMD>< 7-32>
Have somebody implemented thick line algorithm?
« on: June 24, 2018, 07:10:53 AM »
Hi!

I'm fighting a little with Murphy's algorithm... but without success  :icon13:.

Perhaps somebody  :icon14:? (whatever thick line algorithm)

caballero

  • Member
  • *****
  • Posts: 1084
    • abre ojos ensamblador
Re: Have somebody implemented thick line algorithm?
« Reply #1 on: June 24, 2018, 06:20:45 PM »
Yes, I did it. Bresenham line algorithm
En un lugar de la Mancha de cuyo nombre no quiero acordarme

- There are 10 kind of people: those who know binary numbers and those who don't -

Biterider

  • Member
  • **
  • Posts: 222
  • ObjAsm32 - ObjAsm64
    • ObjAsm64
Re: Have somebody implemented thick line algorithm?
« Reply #2 on: June 24, 2018, 07:23:06 PM »
Hello HSE
ObjAsm32 has an object called Pixelmap that supports subpixel drawing.   :idea:
The width of a line can be easily achieved by painting adjacent pixels using Besenham, WU, or other similar algos.
I have slightly modified the demo application to draw wider lines (vertical line with 3 px and inner circle with 2 px)
I attach the new exe.  ;)

Biterider

jj2007

  • Member
  • *****
  • Posts: 8735
  • Assembler is fun ;-)
    • MasmBasic
Re: Have somebody implemented thick line algorithm?
« Reply #3 on: June 24, 2018, 07:28:09 PM »
What's wrong with Gdi+ thick lines?

caballero

  • Member
  • *****
  • Posts: 1084
    • abre ojos ensamblador
Re: Have somebody implemented thick line algorithm?
« Reply #4 on: June 24, 2018, 09:29:44 PM »
GDI/GDI+ routines are quite slow for making some time critical routines like demos
En un lugar de la Mancha de cuyo nombre no quiero acordarme

- There are 10 kind of people: those who know binary numbers and those who don't -

FORTRANS

  • Member
  • *****
  • Posts: 1016
Re: Have somebody implemented thick line algorithm?
« Reply #5 on: June 24, 2018, 09:51:16 PM »
Hi,

   When I made a general purpose line drawing routine, it used
a pixel routine to draw pixels on the screen.  By using different
pixel routines, you got different effects.  Black to draw.  White
to erase.  And then patterned pixels for dashed lines and fat
pixels for thick lines.  Certainly wasn't the fastest, but wasn't
really the slowest either.  Except maybe for the fat pixels.

   Faster line routines set the pixel as part of the line drawing
algorithm.  Not as a separate pixel routine.

HTH,

Steve N.

daydreamer

  • Member
  • ****
  • Posts: 531
  • reach for the stars
Re: Have somebody implemented thick line algorithm?
« Reply #6 on: June 24, 2018, 10:19:01 PM »
it depends on what you mean: line with just bigger fat size,its just easy to output more pixels in pixel macro/proc and call it from line algo
or nicerlooking search for antialiased bresenham,make code that puts some grey pixels around white line or darker shade of color of the line,especially where the sawshaped line looks worst

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

HSE

  • Member
  • ****
  • Posts: 807
  • <AMD>< 7-32>
Re: Have somebody implemented thick line algorithm?
« Reply #7 on: June 25, 2018, 05:37:56 AM »
Yes, I did it. Bresenham line algorithm
No. Bresenham algorithm is only for thin lines  :biggrin:

The width of a line can be easily achieved by painting adjacent pixels using Besenham, WU, or other similar algos.
It's easy if you know line orientation  8)

@FORTRANS && daydreamer :
  It's an expensive solution... but if algorithm don't work   

What's wrong with Gdi+ thick lines?
Perhaps GDI+ or other graphics libraries with antialiasing are better, but now I'm trying to draw fast (and simple if posible).

Thanks for the ideas. Now I have a mix. Thin lines are Bresenham drawings. Over that is a normal thick GDI line, witch in theory it's Murphy's algorithm. The idea is to draw that line and to make nicer points in same process. 


HSE

  • Member
  • ****
  • Posts: 807
  • <AMD>< 7-32>
Re: Have somebody implemented thick line algorithm?
« Reply #8 on: July 03, 2018, 08:22:32 AM »
Using Fortrans and Daydreammer "big pixel" line.

Final result not so impressive  :(

Perhaps an antialiased line it's mandatory...

felipe

  • Member
  • ****
  • Posts: 928
  • Eagles are just great!
Re: Have somebody implemented thick line algorithm?
« Reply #9 on: July 03, 2018, 08:47:00 AM »
Nice project and looks difficult too. Congratulations.  :t
Felipe.

HSE

  • Member
  • ****
  • Posts: 807
  • <AMD>< 7-32>
Re: Have somebody implemented thick line algorithm?
« Reply #10 on: July 06, 2018, 02:06:41 AM »
Nice project and looks difficult too.
Yes, nothing easy, and no time for that!

Using GDI+. With the antialiased thick line is far far better I think.

daydreamer

  • Member
  • ****
  • Posts: 531
  • reach for the stars
Re: Have somebody implemented thick line algorithm?
« Reply #11 on: July 06, 2018, 04:16:33 AM »
wonder how it looks with dx9 line or poly used as line with fullfledged hardware antialias filter?
Quote from Flashdance
Nick  :  When you give up your dream, you die.
*wears a flameproof asbestos suit*

HSE

  • Member
  • ****
  • Posts: 807
  • <AMD>< 7-32>
Re: Have somebody implemented thick line algorithm?
« Reply #12 on: July 06, 2018, 08:20:49 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  :biggrin:

But I was thinking in Biterider solution, I have to see.

Siekmanski

  • Member
  • *****
  • Posts: 1646
Re: Have somebody implemented thick line algorithm?
« Reply #13 on: July 06, 2018, 08:22:28 AM »
What about stretching a circle to a line?
Creative coders use backward thinking techniques as a strategy.

HSE

  • Member
  • ****
  • Posts: 807
  • <AMD>< 7-32>
Re: Have somebody implemented thick line algorithm?
« Reply #14 on: July 06, 2018, 10:46:34 AM »
Apparently Direct2D is better suited for lines, but again examples are very complex