J2ME's fillTriangle is badly broken

A

Alex Hunsley

J2ME's fillTriangle method is badly broken and doesn't honour the
contract of the method.
For example, to make the following code work as it should:


g.fillTriangle(xx + halfButtonWidth,
yy + buttonWidth,
xx + halfButtonWidth, yy,
xx + buttonWidth + 1, yy + halfButtonWidth);

I have to actually write:

g.fillTriangle(xx + halfButtonWidth,
yy + buttonWidth + 1, // note the +1
xx + halfButtonWidth, yy - 1, // note the -1
xx + buttonWidth + 1, yy + halfButtonWidth);

I can't actually work out what it is doing wrong (haven't checked the
J2ME source code for it yet either). It behaves badly in other ways too:
sometimes it will refuse to draw the rightmost and bottommost lines of
pixels for the triangle that should be drawn.

Just out of curiousity, anyone else been there and worked out in what
way fillTriangle is broken? (And how to predictably fix your calls to
fillTriangle so that they behave as the javadoc promises?)

cheers,
lex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top