Re: [AD] About colors

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


On June 15, 2010, Elias Pschernig wrote:
> On Tue, 2010-06-15 at 15:12 -0400, Pavel Sountsov wrote:
> > 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...
> 
> Easy fix: Make lines grow leftwards. Negative thickness makes them grow
> rightwards instead. Thickness 0 means nothing is drawn. (We don't need
> hairlines, given the problems with them.)
> 
> > 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
> 
> It makes a lot of sense however and is consistent. But yes, it will be
> confusing to new users, especially when they come from A4.
> 
> > 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.
> 
> Yes. This is not workable. Also what if the line width is not 1, but 3.
> Or 0.5.
> 
> > 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
> 
> Yes, like 5, we simply don't have pixels any longer with fractional
> coordinates. With transformations and multi-sampling I don't see it
> working that way.
> 
> > 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.
> 
> I like 1. But I also like what I said initial. The example would look
> like this:
> 
> al_draw_filled_rectangle(x1, y1, x1 + w, y1 + h);
> al_draw_rectangle(x1, y1, x1 + w, y1 + h, 1);  // inwards, overlapping
> the filled area al_draw_rectangle(x1, y1, x1 + w, y1 + h, -1); //
> outwards
> al_draw_line(x1, y1 + 1, x1 + w, y1 + 1, 1);   // top (width extends to
> the left) al_draw_line(x1, y1, x1 + w, y1, -1);          // this is the
> same, width extends to the right) al_draw_line(x1, y1 + h, x1 + w, y1 +
> h, 1);   //bottom
> 
> So still, never have to use fraction coordinates. By removing the
> possibility of hairlines, I think it will be easy to explain how the
> thickness works.

I would prefer it to be as much like a4's primitives as possible. A5's 2d 
mode is supposed to be a emulation of the same coordinate space, and have 
the same behaviors afaik.

If Allegro 5's 2d isn't supposed to be simpler and easier to grasp, then 
what is the point?

-- 
Thomas Fjellstrom
tfjellstrom@xxxxxxxxxx




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