Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » How to modifiy line() width

This thread is locked; no one can reply to it. rss feed Print
How to modifiy line() width
Lox Chatterbox
Member #20,176
May 2021

I want to increase the width of the line() function. How should I implement it?

LennyLen
Member #5,313
December 2004
avatar

You'd be best switching to Allegro 5, which allows you to set the thickness of the line.

Todd Cope
Member #998
November 2000
avatar

There are a several ways to accomplish this in Allegro 4. I'll list a few below:

  1. do_line()

  2. polygon()

  3. rectfill()

do_line() is probably the easiest. I would probably just pass it a callback that renders a circle that has a diameter the desired thickness. These circles should be centered around the x- and y-coordinates Allegro passes to the callback. This is somewhat wasteful as it will rewrite many pixels as the line is drawn. It may not matter depending on what you are trying to accomplish.

rectfill() can be used if your line is parallel to the grid of pixels.

polygon() will require you to do some trigonometry to get the positions of the vertices needed to make the line.

Go to: