Tk Source Code

View Ticket
Login
Ticket UUID: f6e4d4ca304e9de13922d3a53adc65913bce6d14
Title: polygon items filled differently depending on platform
Type: Bug Version: 8.6.11
Submitter: Akuli Created on: 2022-05-15 10:00:58
Subsystem: 05. Canvas Items Assigned To: fvogel
Priority: 3 Low Severity: Minor
Status: Closed Last Modified: 2022-08-22 19:19:55
Resolution: Fixed Closed By: fvogel
    Closed on: 2022-08-22 19:19:55
Description:
The following code produces very different looking results on Windows and Linux. On Windows, the middle part where the polygon overlaps itself is filled. On Linux it is not. Screenshot: https://i.imgur.com/Zx6nKWo.png

package require Tk
puts [info patchlevel]
canvas .c
pack .c
.c create polygon 100 100 200 200 100 200 200 100 100 150 200 150 -fill red

This should be at least mentioned in documentation.
User Comments: fvogel added on 2022-08-22 19:19:55:
Merged to core-8-6-branch and trunk.

jan.nijtmans added on 2022-08-21 22:06:11:

Good catch! +1


fvogel added on 2022-08-21 16:58:19:

Documentation of the use of the even-odd fill rule added in [863f9ede].

This bug in the X11 emulation on Windows was present since the beginning of time (first commit in 1998).


fvogel added on 2022-08-21 16:48:53:

Totally agreed. Fix committed in [bf11afd4].


chrstphrchvz added on 2022-08-09 16:49:33:

See attached patch: the X GC fill rule is incorrectly initialized to WindingRule by default on non-X11. This bug would’ve affected Aqua had it also supported winding rule fill rather than hardcoded even-odd rule fill: [4a59d535d1c0]


chrstphrchvz added on 2022-08-09 16:10:49:

The screenshot appears to show winding rule fill being used on Windows while even-odd rule fill is used on X11.

Polygon fills are handled by XFillPolygon(), and whether it uses winding rule or even-odd rule is determined by the fill rule in the X graphics context it is provided; it is even-odd by default. Nowhere does core Tk explicitly set the fill rule for an X GC, so it implicitly uses even-odd; maybe this should be documented, although in theory an option could be introduced to control which of the two is used. So I’m inclined to believe this is a bug in X11 emulation on Windows.


Attachments: