On Wed, 20 Sep 2000, Lee Brown wrote:
> 2) While looking at the GGI API it struck me that there is ggiPutHLine,
> ggiGetHline, ggiPutVline, ggiGetVline. Why isn't there a ggiPutLine
> ggiGetLine?
Because it's not a function whose behavior is particularly easy to
understand from a user perspective, and not one that is very useful
since it will behave in a way that users will find suboptimal. It
is also not as likely to be available as an accelerated primitive, and
may be a bit more complicated than you think.
All the LibGGI primitives are pretty straightforward, that is, there
is a very straightforward way to go about putting an hline full
of pixels from memory to the screen. You take one pixel out of the
buffer and put it at the first location in the hline, and so on.
But when you get to diagonal lines, it is much more complex. There
is more than one way, for example, to draw a line from 0,0 to 2,1:
x
xx
and
xx
x
and
xx
xx
In fact, as minor as this may seem, there is an exact standard for this
in LibGGI that must be followed by all targets, and it is complicated by
clipping. That would make it technically possible to implement the
function in a standard way as well. However, the standard we (and most of
the graphics industry) chose is one that can be implemented by a fast
tight-loop algorithm. Lines are often drawn backwards from the second
endpoint to the first, and calculations are done on the clipping rectangle
to avoid running that tight loop for points that are outside the clip --
which means you would first have to do a lot of calcuation to figure out
what the first/last point in the buffer to be used will be and which
direction you'll be moving in the buffer.
However, how useful is it to be able to put a buffer into these coordinates?
... the user would have to have intimate knowlege of the drawing algorithm
to get the different colored pixels where they want them. If you were to
draw a radial pattern, it would be full of moire effects, which is
probably not what the user wants. The user is more likely to want to
define a buffer that defines a gradient to fill the line with, and
while they are at it, antialiased and with an optional width parameter.
Basically, it would be more useful in a 2d library that did gradient/texture
stretching, or tesslation, of the buffer pattern.
--
Brian