Announcement

Collapse
No announcement yet.

PolygonFilled function works improperly

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PolygonFilled function works improperly

    Please test this code:

    var x[4] := [2, 6, 6, 2];
    var y[4] := [2, 2, 6, 6];
    gfx_PolygonFilled(4, x, y, RED);

    It is supposed to produce a 5x5-pixel square located two pixels away from upper left corner in either direction.
    Instead, it results in a 5x4-pixel rectangle, the first (upper) line of pixels missing.

    Setting var yIN[4] := [1, 1, 6, 6]; does produce the desired result, but then the entire upper line of pixels (with y = 0) becomes inaccessible for this function...

    Well, I have also tried var yIN[4] := [-1, -1, 5, 5];, and it works!

    But, nevertheless, setting (x2 - x1) = (y2 - y1) must produce a square. So this function has a bug somewhere.





  • #2
    Hmm, yeah.

    The lowest Y values for a filled polygon are not produced.

    This can be easily seen with

    Code:
        gfx_Polygon(4, x, y, LIME);
        gfx_PolygonFilled(4, x, y, RED);
    A quick workaround is

    Code:
        gfx_OutlineColour(RED);                // 8  graphics rectangle/circle outline colour
        gfx_PolygonFilled(4, x, y, RED);
    Mark

    Comment


    • #3
      Thank you, I'll check this. But I'm actually interested in more complex shapes like arrows (they came out distorted, so I decided to test squares).
      Do you think adding the outline will work for them as well?

      Comment


      • #4
        I think it will, by all means give it a try, and perhaps come back with a more complex example, it will help test the fix
        Mark

        Comment


        • #5
          Well, it works for a 7-point arrow. The gfx_Polygon function (outline only) works OK.

          Thank you.

          Comment

          Working...
          X