Re: [AD] About colors

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


> On Tue, 2010-06-15 at 11:11 -0400, Pavel Sountsov wrote:
> >
> > So you're proposing not changing the current behaviour at all.
> >
>
> Not that one for filled primitives, yes.
>
> > I think the problem at hand is that OpenGL way, while
understandable
> > given knowledge of how OpenGL chooses what pixels to draw, is
> > completely unintuitive to users. To get al_draw_filled_rectangle
and
> > al_draw_rectangle to line up at least one of them will have to be
> > changed to work in the way that is not obvious from OpenGL point
of
> > view.
>
> Yes. Personally, I think the current way is fine.
>
> I wouldn't mind if the thickness grows only inwards or only
outwards
for
> al_draw_rectangle though. It would mean as long as you always
specify
> full integer positions, you will always get fully covered pixels.

Hmm, yes... having the thickness growing inwardly will make
al_draw_rectangle and al_draw_filled_rectangle use the same
coordinates
(right?). The only problem with that is that it is completely
inconsistent with pretty much every drawing program on the planet...
however, I think this is the best compromise from the point of view
of
user friendliness and OpenGL reality.

-SiegeLord

This doesn't fix it for lines, however, since they don't have an 'inward' side. It seems very difficult to get all 3 functions to behave consistently...

Here are the alternatives so far: the task is to draw a rectangle with an outline. We also want to highlight the top and bottom edges with a different color using lines.

1. Current implementation:

al_draw_filled_rectangle(x1, y1, x1 + w, y1 + h);
al_draw_rectangle(x1 + 0.5, y1 + 0.5, x1 + w - 0.5, y1 + h - 0.5);
al_draw_line(x1, y1 + 0.5, x1 + w, y1 + 0.5);         //top
al_draw_line(x1, y1 + h - 0.5, x1 + w, y1 + h - 0.5); //bottom

Pros: Rectangle growing in thickness symmetrically is nice and expected
Cons: All 3 functions require different offsets

2. Make rectangle thickness grow inwardly

al_draw_filled_rectangle(x1, y1, x1 + w, y1 + h);
al_draw_rectangle(x1, y1, x1 + w, y1 + h);
al_draw_line(x1, y1 + 0.5, x1 + w, y1 + 0.5);         //top
al_draw_line(x1, y1 + h - 0.5, x1 + w, y1 + h - 0.5); //bottom

Pros: Filled rectangle and outline use the same offsets
Cons: Rectangle grows inwards in thickness, which can be surprising

3. Make lines grow in length as well as thickness (something like semicircular endcaps)

al_draw_filled_rectangle(x1, y1, x1 + w, y1 + h);
al_draw_rectangle(x1 + 0.5, y1 + 0.5, x1 + w - 0.5, y1 + h - 0.5);
al_draw_line(x1 + 0.5, y1 + 0.5, x1 + w - 0.5, y1 + 0.5);         //top
al_draw_line(x1 + 0.5, y1 + h - 0.5, x1 + w - 0.5, y1 + h - 0.5); //bottom

Pros: "Line" primitives, the outline and individual lines, use the same offsets
Cons: Rectangle and outline have different offsets

4. Combine 2 and 3

al_draw_filled_rectangle(x1, y1, x1 + w, y1 + h);
al_draw_rectangle(x1, y1, x1 + w, y1 + h);
al_draw_line(x1 + 0.5, y1 + 0.5, x1 + w - 0.5, y1 + 0.5);         //top
al_draw_line(x1 + 0.5, y1 + h - 0.5, x1 + w - 0.5, y1 + h - 0.5); //bottom

Pros: Same as 2
Cons: Same as 2

5. #3 but with a global 0.5 shift for lined primitives

al_draw_filled_rectangle(x1, y1, x1 + w, y1 + h);
al_draw_rectangle(x1, y1, x1 + w - 1, y1 + h - 1);
al_draw_line(x1, y1, x1 + w - 1, y1);                 //top
al_draw_line(x1, y1 + h - 1, x1 + w - 1, y1 + h - 1); //bottom

Pros: No more 0.5 offsets
Cons: Not sure how it works with transformations. The passed coordinate no longer directly relate to the OpenGL calls. Rectangle and outline have different offsets.

6. #5 but with A4 semantics (x2, y2 corner is inclusive)

al_draw_filled_rectangle(x1, y1, x1 + w - 1, y1 + h - 1);
al_draw_rectangle(x1, y1, x1 + w - 1, y1 + h - 1);
al_draw_line(x1, y1, x1 + w - 1, y1);                 //top
al_draw_line(x1, y1 + h - 1, x1 + w - 1, y1 + h - 1); //bottom

Pros: Same offsets for every function
Cons: Same as 5

Opinions? Should I make a poll about this on a.cc?

I kind of like 3, since it's consistent... 6 is attractive, but the cons might be too much.

I mean, in the end, all those offsets can be documented... but it seems wrong to me that RTFM'ing is required for such 'simple' functions.

-SiegeLord




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/