On 21.06.2017 13:01 Albrecht Schlosser wrote:
> On 20.06.2017 12:19 schrieb holm.haavard@.. wrote:
>
>> Still struggeling.. The following code was expected to draw three
>> separate quads, however I also get something between..
>
> What is "something" ?
Ah, I see, it's a filled triangle connecting the quads.
Okay, I was curious and did it myself, see the attached file polygon.cxx
that got longer and more complex than I had intended.
Some comments:
If you want to draw separate objects you should use separate polygon
drawing calls in FLTK, i.e. don't use fl_gap() but use fl_end*polygon;
fl_begin*polygon; between these separate objects.
In your example you're drawing three separate, complex, poygons. There's
no need to use fl_begin/end_complex_polygon though if that's what you
intend to do: you can use the faster and more accurate
fl_begin/end_polygon instead. polygon.cxx shows this if you define
COMPLEX = 0.
Your original code is kinda replicated if you set COMPLEX = 1 and
USE_GAP = 1. I'm additionally setting fl_color() to different values.
Change USE_GAP => 0 to get what you supposedly intended to get.
Separate objects can have different colors, which the example program
shows. If you draw one complex polygon only (with USE_GAP = 1) there is
only one color (in this case the last one: FL_RED).
To avoid changing coordinates of your original code so would draw inside
the box boundaries I added a translation.
There's no guarantee that this code is entirely correct or best
practice, but it works for me and does what I think you intended to do:
set COMPLEX = 0 or 1 (0 preferred, see above)
set USE_GAP 0 (only relevant if you use COMPLEX = 1)