Line drawing with Bresenham more than one pixel thick

  • Follow


Hello,

I am using the Bresenham algorithm to draw single pixel lines with no
problems. However I would like to draw some lines which are more than
one pixel thick. Is there a modification to this algorithm that I can
use or can anyone point me to an algorithm or resource that I can use
to investigate / achieve this?

Many thanks in advance

Gary
0
Reply Gazza 4/8/2010 8:35:48 AM

On 04/ 8/10 08:35 PM, Gazza wrote:
> Hello,
>
> I am using the Bresenham algorithm to draw single pixel lines with no
> problems. However I would like to draw some lines which are more than
> one pixel thick. Is there a modification to this algorithm that I can
> use or can anyone point me to an algorithm or resource that I can use
> to investigate / achieve this?

Do you have a C question?  You appear to posted to the wrong group.

-- 
Ian Collins
0
Reply Ian 4/8/2010 8:56:37 AM


On 8 Apr, 09:56, Ian Collins <ian-n...@hotmail.com> wrote:
> On 04/ 8/10 08:35 PM, Gazza wrote:
>
> > Hello,
>
> > I am using the Bresenham algorithm to draw single pixel lines with no
> > problems. However I would like to draw some lines which are more than
> > one pixel thick. Is there a modification to this algorithm that I can
> > use or can anyone point me to an algorithm or resource that I can use
> > to investigate / achieve this?
>
> Do you have a C question? =A0You appear to posted to the wrong group.
>
> --
> Ian Collins

The question is related to C as that is what the algorithm is coded in
which I am currently using. I searched this group and there are
several questions relating to this algorithm already so I thought that
it would be a good forum to ask as people were using it already and
may had had the same issue or know about adapting it to construct
lines of more than one pixel thick. Any help would be appreciated.

Gary
0
Reply Gazza 4/8/2010 12:07:29 PM

Gazza <garywi25@googlemail.com> wrote:
> On 8 Apr, 09:56, Ian Collins <ian-n...@hotmail.com> wrote:
> > On 04/ 8/10 08:35 PM, Gazza wrote:
> > > I am using the Bresenham algorithm to draw single pixel lines with no
> > > problems. However I would like to draw some lines which are more than
> > > one pixel thick. Is there a modification to this algorithm that I can
> > > use or can anyone point me to an algorithm or resource that I can use
> > > to investigate / achieve this?
> >
> > Do you have a C question?  You appear to posted to the wrong group.

> The question is related to C as that is what the algorithm is coded in
> which I am currently using. 

Just because you write something in C doesn't make it on-topic
in a group about the C language (and not about everything that
can be written in this language - since C is a Touring-complete
language there otherwise would be nearly no limit to the topi-
cality;-).

> I searched this group and there are
> several questions relating to this algorithm already 

The last time the word "bresenham" was mentioned in this group
was, at least according to Google, about 9 years ago, and here's
a short citation from that thread from 2001:

| It is off topic here; the newsgroup for computer graphics algorithms
| is, perhaps surprisingly, comp.graphics.algorithms.

I don't know if comp.graphics.algorithms still exists and is
active, otherwise I would guess that you will have a lot more
luck in e.g. comp.programming where discussions of specific
algorithms is definitely on-topic.

                          Regards, Jens
-- 
  \   Jens Thoms Toerring  ___      jt@toerring.de
   \__________________________      http://toerring.de
0
Reply jt 4/8/2010 12:59:04 PM

  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

---1247968617-1707918480-1270737072=:28077
Content-Type: TEXT/PLAIN; CHARSET=iso-8859-2; format=flowed
Content-Transfer-Encoding: 8BIT
Content-ID: <Pine.LNX.4.64.1004081632001.28077@login01.caesar.elte.hu>

On Thu, 8 Apr 2010, Gazza wrote:

> On 8 Apr, 09:56, Ian Collins <ian-n...@hotmail.com> wrote:
>> On 04/ 8/10 08:35 PM, Gazza wrote:
>>
>>> Hello,
>>
>>> I am using the Bresenham algorithm to draw single pixel lines with no
>>> problems. However I would like to draw some lines which are more than
>>> one pixel thick. Is there a modification to this algorithm that I can
>>> use or can anyone point me to an algorithm or resource that I can use
>>> to investigate / achieve this?
>>
>> Do you have a C question? �You appear to posted to the wrong group.
>>
>> --
>> Ian Collins
>
> The question is related to C as that is what the algorithm is coded in
> which I am currently using. I searched this group and there are
> several questions relating to this algorithm already so I thought that
> it would be a good forum to ask as people were using it already and
> may had had the same issue or know about adapting it to construct
> lines of more than one pixel thick. Any help would be appreciated.

Have you considered the brute force idea of:
- compute a slope orthogonal (.) to the line's slope (*)
- compute the vertices of a rotated rectangle based on line thickness (#)
- rasterize the rectangle "somehow":

   #o
   . oo
..**   oo
..  **   oo
#o   **   oo
   oo   **   o#
     oo   **  .
       oo   **.
         oo .
           o#

You could split this rectangle into three parts, an upper triangle, a 
middle parallelogram, and a lower triangle. You could write a single loop 
scanning the Y axis top-down, maintaining a "phase" flag or so. Or you 
could write three loops.

Phase 1: track original slope on the right with Bresenham's, track the 
orthogonal slope on the left with Bresenham's, draw a horizontal segment 
between them, for each distinct Y value.

Phase 2: switch to the original slope on the left.

Phase 3: switch to the orthogonal slope on the right.

You'll have to "unpack" the drawline() function and "fuse" two instances, 
ie. execute two drawline()'s in lockstep, in parallel.

http://en.wikipedia.org/wiki/Loop_fusion

(This idea is worth exactly as much as you've paid for it. And I'm sure 
c.l.c is liberal enough, all semblance notwithstanding, to allow me to 
veer off to this exact topic :P)

lacos
---1247968617-1707918480-1270737072=:28077--
0
Reply Ersek 4/8/2010 2:47:27 PM

On 2010-04-08, Gazza <garywi25@googlemail.com> wrote:
> The question is related to C as that is what the algorithm is coded in
> which I am currently using.

That doesn't make it about C.

Would the answer to your question be changed in ANY way by using perl?
No, it would not.  Would it be changed in ANY way by a shift from pre-K&R
C to C99?  No, it would not.

It hasn't got anything to do with the language.

The issue here is that the topic here is the C language, not any program
which happens to be in C.  If the issues you're encountering aren't specific
to a given language (and they aren't), you probably want comp.programming
or somesuch.

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
0
Reply Seebs 4/8/2010 5:01:04 PM

In article <c8177466-965a-4b49-9d11-425251830fb2@
11g2000yqr.googlegroups.com>, garywi25@googlemail.com says...
> 
> Hello,
> 
> I am using the Bresenham algorithm to draw single pixel lines with no
> problems. However I would like to draw some lines which are more than
> one pixel thick. Is there a modification to this algorithm that I can
> use or can anyone point me to an algorithm or resource that I can use
> to investigate / achieve this?

You want news:comp.graphics.algorithms
FAQ:
http://www.faqs.org/faqs/graphics/algorithms-faq/
0
Reply Dann 4/8/2010 5:32:59 PM

Jens Thoms Toerring wrote:
> Gazza <garywi25@googlemail.com> wrote:

>> The question is related to C as that is what the algorithm is coded in
>> which I am currently using. 
> 
> Just because you write something in C doesn't make it on-topic
> in a group about the C language (and not about everything that
> can be written in this language - since C is a Touring-complete
> language there otherwise would be nearly no limit to the topi-
> cality;-).

Your mispelling of Dr. Turing's name is a funny little mini-error, 
because I believe he has the same name as you.  In Berlin we would say 
the place name with an initial 'd' instead of 't'.  Wasn't it a Bezirk 
in the ddr?
-- 
Uno
0
Reply Uno 4/9/2010 8:31:16 AM

On Apr 8, 9:35=A0am, Gazza <garyw...@googlemail.com> wrote:
> Hello,
>
> I am using the Bresenham algorithm to draw single pixel lines with no
> problems. However I would like to draw some lines which are more than
> one pixel thick. Is there a modification to this algorithm that I can
> use or can anyone point me to an algorithm or resource that I can use
> to investigate / achieve this?

Sure. But I think you would first have to define what you actually
want to draw. If the line is say ten pixel thick, do you want to draw
a rectangle rotated into the right position, or a parallelogram?
0
Reply christian 4/10/2010 1:08:16 AM

In article <ef2503e6-6606-4c72-94fb-ce3fc3588c41
@q23g2000yqd.googlegroups.com>, christian.bau@cbau.wanadoo.co.uk says...
> 
> On Apr 8, 9:35�am, Gazza <garyw...@googlemail.com> wrote:
> > Hello,
> >
> > I am using the Bresenham algorithm to draw single pixel lines with no
> > problems. However I would like to draw some lines which are more than
> > one pixel thick. Is there a modification to this algorithm that I can
> > use or can anyone point me to an algorithm or resource that I can use
> > to investigate / achieve this?
> 
> Sure. But I think you would first have to define what you actually
> want to draw. If the line is say ten pixel thick, do you want to draw
> a rectangle rotated into the right position, or a parallelogram?

Typically neither.

When I had the same problem, I inserted pie slices into the gaps where 
the segments change direction (for non-raster devices like pen 
plotters).  If you have a raster device, then you can just add a circle 
the same diameter as the the line segments at the ends of all interior 
direction changes.
0
Reply Dann 4/10/2010 3:06:50 AM

On 10 Apr, 04:06, Dann Corbit <dcor...@connx.com> wrote:
> In article <ef2503e6-6606-4c72-94fb-ce3fc3588c41
> @q23g2000yqd.googlegroups.com>, christian....@cbau.wanadoo.co.uk says...
>
>
>
> > On Apr 8, 9:35=A0am, Gazza <garyw...@googlemail.com> wrote:
> > > Hello,
>
> > > I am using the Bresenham algorithm to draw single pixel lines with no
> > > problems. However I would like to draw some lines which are more than
> > > one pixel thick. Is there a modification to this algorithm that I can
> > > use or can anyone point me to an algorithm or resource that I can use
> > > to investigate / achieve this?
>
> > Sure. But I think you would first have to define what you actually
> > want to draw. If the line is say ten pixel thick, do you want to draw
> > a rectangle rotated into the right position, or a parallelogram?
>
> Typically neither.
>
> When I had the same problem, I inserted pie slices into the gaps where
> the segments change direction (for non-raster devices like pen
> plotters). =A0If you have a raster device, then you can just add a circle
> the same diameter as the the line segments at the ends of all interior
> direction changes.

Thanks for all of your comments. I will be more careful next time when
posting a question to a group. I thought that more or you would be
interested in solving the issue than complaining about using the wrong
group. Many apologies if I offended anyone by asking a question I
thought that you would be able to answer as C programmers. Special
thanks to those who actually gave some guidance.

Gary
0
Reply Gazza 4/12/2010 11:23:20 AM

Gazza <garywi25@googlemail.com> writes:
[...]
> Thanks for all of your comments. I will be more careful next time when
> posting a question to a group. I thought that more or you would be
> interested in solving the issue than complaining about using the wrong
> group. Many apologies if I offended anyone by asking a question I
> thought that you would be able to answer as C programmers. Special
> thanks to those who actually gave some guidance.

Part of the purpose of redirecting a question to a more appropriate
group is that you can get more and better answers there, and those
answers can be checked by more people who are actually familiar with
the topic.

The other part of the purpose is that the signal-to-noise ratio here
is low enough as it is.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
0
Reply Keith 4/12/2010 4:01:54 PM

On 2010-04-12, Keith Thompson <kst-u@mib.org> wrote:
> Gazza <garywi25@googlemail.com> writes:
> [...]
>> Thanks for all of your comments. I will be more careful next time when
>> posting a question to a group. I thought that more or you would be
>> interested in solving the issue than complaining about using the wrong
>> group. Many apologies if I offended anyone by asking a question I
>> thought that you would be able to answer as C programmers. Special
>> thanks to those who actually gave some guidance.

> Part of the purpose of redirecting a question to a more appropriate
> group is that you can get more and better answers there, and those
> answers can be checked by more people who are actually familiar with
> the topic.

Yes.  I could give all sorts of advice about line drawing algorithms, but
you'd have to be pretty dumb to take my advice on it, because the sole
extent of my actual experience is refactoring a 3-page function written
in pascal into a 15-line function in C for use in a roguelike game.

I would guess that the vast majority of C programmers have never had
any reason to write a line-drawing algorithm outside of some kind of
toy project in school, but that the vast majority of graphics programmers,
regardless of language, will be at least basically familiar with the
range.

Basically, it's silly to expect people to be more interested in solving
a problem that's of no interest to them and of no relevance to their fields
of study and work, than they are in suggesting that you ask people whose
line of work it would be in.

Would you come to a group of mathematicians to ask for advice about
double-entry bookkeeping, on the grounds that it's done by some kind of
arithmetic, which is a branch of mathematics?

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
0
Reply Seebs 4/12/2010 4:41:52 PM

12 Replies
875 Views

(page loaded in 0.096 seconds)

Similiar Articles:








7/22/2012 2:28:10 PM


Reply: