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
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.
Gary
> 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 ___ j...@toerring.de
\__________________________ http://toerring.de
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
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...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
You want news:comp.graphics.algorithms
FAQ:
http://www.faqs.org/faqs/graphics/algorithms-faq/
>> 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
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.
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
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) ks...@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"
> 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?