Tk Source Code

View Ticket
Login
2025-11-03
17:06 • Closed ticket [6051a9fc]: On windows, arcs with small 'extent' can be drawn incorrectly plus 7 other changes artifact: a791cbb8 user: oehhar
17:02
bugfix [6051a9fc]: MS-Win canvas arcs with to small extend are drawn as 360 degrees, but bool type to int type. check-in: 7a2bfd86 user: oehhar tags: core-8-6-branch
16:57
bugfix [6051a9fc]: MS-Win canvas arcs with to small extend are drawn as 360 degrees check-in: 812237e0 user: oehhar tags: core-9-0-branch
16:54
bugfix [6051a9fc]: MS-Win canvas arcs with to small extend are drawn as 360 degrees check-in: 6f1ecbab user: oehhar tags: trunk, main
2025-10-31
13:14 • Ticket [6051a9fc] On windows, arcs with small 'extent' can be drawn incorrectly status still Open with 4 other changes artifact: 05497bed user: oehhar
13:07 • Add attachment widget_demo_canvas_items_ovals_patch-artefact_no-patch.png to ticket [6051a9fc] artifact: 02ef1042 user: oehhar
10:46 • Ticket [6051a9fc] On windows, arcs with small 'extent' can be drawn incorrectly status still Open with 3 other changes artifact: 171143c9 user: jan.nijtmans
2025-10-30
14:28 • Ticket [6051a9fc]: 3 changes artifact: edcf958c user: chrstphrchvz
2025-10-27
08:55
[6051a9fc] Also back-out changes message check-in: 356e364f user: oehhar tags: core-9-0-branch
2025-10-26
09:54 • Ticket [6051a9fc] On windows, arcs with small 'extent' can be drawn incorrectly status still Open with 4 other changes artifact: 830a5b81 user: oehhar
09:52
[6051a9fc] back out solution fix and go back to branch: oval drawing issue found check-in: 0200b4c1 user: oehhar tags: core-9-0-branch
09:51
[6051a9fc] back out solution fix and go back to branch: oval drawing issue found check-in: 9a639671 user: oehhar tags: core-8-6-branch
09:46
[6051a9fc] back out solution fix and go back to branch: oval drawing issue found check-in: 0ef7d5d7 user: oehhar tags: trunk, main
09:42 • Open ticket [6051a9fc]: On windows, arcs with small 'extent' can be drawn incorrectly plus 4 other changes artifact: 9b5d4eba user: oehhar
2025-10-25
20:37 • Ticket [6051a9fc]: 5 changes artifact: bc00c097 user: chrstphrchvz
2025-10-21
08:10 • Ticket [1081603f] Arc item anomalies under Windows status still Open with 4 other changes artifact: 26a47715 user: oehhar
08:05 • Closed ticket [6051a9fc]: On windows, arcs with small 'extent' can be drawn incorrectly plus 8 other changes artifact: 7a0e351c user: oehhar
08:01
bugfix [6051a9fc]: MS-Win canvas arcs with to small extend are drawn as 360 degrees check-in: f931dc9d user: oehhar tags: core-8-6-branch
07:56
bugfix [6051a9fc]: MS-Win canvas arcs with to small extend are drawn as 360 degrees check-in: 4a7631db user: oehhar tags: core-9-0-branch
07:51
bugfix [6051a9fc]: MS-Win canvas arcs with to small extend are drawn as 360 degrees check-in: dfda5dd3 user: oehhar tags: trunk, main
07:48 • Ticket [6051a9fc] On windows, arcs with small 'extent' can be drawn incorrectly status still Open with 4 other changes artifact: 81851f71 user: oehhar
07:25 • Ticket [6051a9fc]: 4 changes artifact: c4b476bb user: oehhar
2025-10-20
16:53 • Ticket [6051a9fc]: 4 changes artifact: c66f2ea1 user: oehhar
16:43 • Ticket [6051a9fc]: 3 changes artifact: af98158b user: chrstphrchvz
15:38 • Ticket [6051a9fc]: 4 changes artifact: ee8b0038 user: oehhar
15:34 • Ticket [6051a9fc]: 4 changes artifact: cbb97f31 user: oehhar
15:08 • Ticket [6051a9fc]: 3 changes artifact: 75d28b8a user: oehhar
15:06 • Ticket [6051a9fc]: 4 changes artifact: 7343d6a8 user: oehhar
14:39 • Ticket [6051a9fc]: 4 changes artifact: 8b6e4a23 user: anonymous
2025-10-18
21:50 • Ticket [6051a9fc]: 3 changes artifact: cf192d29 user: chrstphrchvz
2025-10-17
23:23 • Ticket [6051a9fc]: 3 changes artifact: dd058cda user: chrstphrchvz
2025-10-16
08:11 • Ticket [6051a9fc]: 4 changes artifact: 84b42d75 user: oehhar
2025-10-15
19:41 • Ticket [6051a9fc]: 3 changes artifact: e1844b4d user: chrstphrchvz
08:47 • Ticket [6051a9fc]: 4 changes artifact: 4c7fb572 user: oehhar
08:43
Ticket [6051a9fc] On MS-Win, small arc segments are filles 360° instead of 0°: fix by Christopher (Thanks!) check-in: 2c3275d0 user: oehhar tags: 6051a9fc-win-arc-small
2025-10-14
21:09 • Ticket [6051a9fc] On windows, arcs with small 'extent' can be drawn incorrectly status still Open with 3 other changes artifact: c50553ef user: chrstphrchvz
07:22 • Add attachment example_1_win11_64bit_undroidwish.png to ticket [6051a9fc] artifact: afcd493d user: oehhar
07:21 • Ticket [6051a9fc] On windows, arcs with small 'extent' can be drawn incorrectly status still Open with 4 other changes artifact: b3dcf7b1 user: oehhar
07:10 • Add attachment example_1_win11_64bit_tk9.0.2.png to ticket [6051a9fc] artifact: fe96d507 user: oehhar
2025-10-13
21:18 • Ticket [6051a9fc] On windows, arcs with small 'extent' can be drawn incorrectly status still Open with 3 other changes artifact: 449652c1 user: anonymous
21:14 • Add attachment screenshot_Mon13Oct2025__22_04_34.png to ticket [6051a9fc] artifact: aeb490ff user: anonymous
01:03 • New ticket [6051a9fc] On windows, arcs with small 'extent' can be drawn incorrectly. artifact: 83489fb1 user: anonymous

Ticket UUID: 6051a9fca29285ce0b545c61413a713eeda33e01
Title: On windows, arcs with small 'extent' can be drawn incorrectly
Type: Bug Version: 9.0
Submitter: anonymous Created on: 2025-10-13 01:03:02
Subsystem: 05. Canvas Items Assigned To: oehhar
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2025-11-03 17:06:29
Resolution: Fixed Closed By: oehhar
    Closed on: 2025-11-03 17:06:29
Description:

Hi,

On windows, 'arc' canvas items with small -extent value, which should appear as a tiny sliver of a pie slice, are sometimes drawn as an entire pie - wrapping around from very small to very big. Whether or not this happens seems to depend on the size of the arc item, the -start value, and the -extent value itself.

Here is a Tcl script that demonstrates the problem:

# ----

package require Tk

canvas .c -width 200 -height 200 -background black
pack .c -expand 1 -fill both

.c create arc 2 2 199 199 \
 -outline pink \
 -fill red \
 -activeoutline "#00ff00" \
 -activefill white \
 -start 0.1 \
 -extent 0.1

wm title . "Testing: $tcl_platform(os)"

# ----

In order to reproduce the problem, run this script on Unix (x11), and run it on Windows.

Observe that on Unix/x11, the 'arc' appears as a tiny sliver, so small that it looks just like a line segment.

Observe that on Windows, the arc appears as a full circle with a line through it, and when you hover the mouse over the line, the small rectangular area containing the tiny sliver pie slice lights up white (the -activefill colour) and the rest of the circle does not light up.

The highlighting behaviour when hovering the mouse over the area that is supposed to be filled by the arc, reveals that the drawing behaviour is incorrect - the 'collision detection' code clearly believes that the arc is a tiny sliver and not a whole pie.

Regards, dhr

User Comments: oehhar added on 2025-11-03 17:06:29:

Merged revised version:

  • 8.6: [7a2bfd86] (with type bool replaced by type int)
  • 9.0: [812237e0]
  • 9.1: [6f1ecbab]

Thanks Christopher and eternal Francois for the fix ! Harald


oehhar added on 2025-10-31 13:14:52:

I have verified the widget demo issue for ovals, which is critical. Ovals are drawn highly obscured. The comparison picture is attachement [widget_demo_canvas_items_ovals_patch-artefact_no-patch.png].

I can say, that the oval artefacts are gone with the patch by Christopher. Great work, I appreciate !

So I would be in favor to merge the branch now. If there is no objection, I will do so next Monday.

Thanks for all, Harald


jan.nijtmans added on 2025-10-31 10:46:59:

It would be nice if this fix appears in Tk 9.0.3. Release cycle will start soon .....


chrstphrchvz added on 2025-10-30 14:28:14:

Please have a look at [a89a807d], which is another attempted fix for both this ticket and the oval item regression. I do not mean to take credit for it though, as I have peeked at the source for the actual X11 server arc fill routines: https://github.com/XQuartz/xorg-server/blob/0ea9b59/mi/mifillarc.c#L678. These clamp the extent to ±360 degrees, which makes sense since it is historically constrained to the signed 16-bit range which itself is not much larger than [-64*360,64*360].


oehhar added on 2025-10-26 09:54:55:

Thanks. It is better to know bad knews. Backed out by:

  • main: [0ef7d5d7]
  • conre-9-0-branch: [0200b4c1]
  • core-8-6-branch: [9a639671]

Thanks, Harald


chrstphrchvz added on 2025-10-25 20:37:06:

Unfortunately the change for this issue has introduced a regression where oval items no longer draw properly (see e.g. canvas items widget demo) and might need to be backed out for now. Sorry for the inconvenience.


oehhar added on 2025-10-21 08:05:42:

Fix merged to all branches:

  • core-8-6-branch: [f931dc9d]
  • core-9-0-branch: [4a7631db]
  • main: [dfda5dd3]

Thanks for Christopher and Francois for the bugfix, highly appreciated. All but one bugfix for Tk in upcoming Tk 8.6 release are from Christopher. Thanks for the action !

Closing.

Take care, Harald


oehhar added on 2025-10-21 07:48:16:

I have made a local test. The test does not fail for me. So, it is probably a timeout issue.

I will merge now.

Thanks for all, Harald


oehhar added on 2025-10-21 07:25:47:

There is one canvas test with images failing:

https://github.com/tcltk/tk/actions/runs/18675528966/job/53244610140#step:9:310

I will try to run manually.

Thanks, Harald


oehhar added on 2025-10-20 16:53:29:
Ok. CI scheduled. Will merge when result is positive.
I don't think there is any issue which might be detected by CI but anyway.

Thanks,
Harald

chrstphrchvz added on 2025-10-20 16:43:02:

Yes, I think this is ready to merge. Thanks again


oehhar added on 2025-10-20 15:38:12:

Christopher, looks good to me, thanks.

Test it, works great.

For me, it may be merged to main, core-9-0 and core-8-6.

Shall I do that?

Thanks, Harald


oehhar added on 2025-10-20 15:34:48:

The recipe does not work. You need a tcl9.1, as this is tk9.1 now. Best would be to use a tcl from the main branch. The naming of the folders should be tcl9.1 and tk9.1. This allows to avoid the specification of TCLDIR=c:\test\... when building tk. But it does not hurt.

Sorry, Harald


oehhar added on 2025-10-20 15:08:49:
One error:

cd c:\test\tk9.0.2\tk -> cd c:\test\tk9.0.2\win

oehhar added on 2025-10-20 15:06:40:

@ drh:

  • Create a build folder. Example: c:\test
  • Take the tcl 9.0.2 distribution and expand it to c:\test\tcl9.0.2
  • Login as anonymous on core.tcl-lang.org/tk
  • Download the zip of the tk branch here: https://core.tcl-lang.org/tk/info/06a80feb6edd0aa6 (button "zip archive")
  • expand it beside in the folder c:\test to get folder c:\test\tk-06a80feb
  • rename folder "tk-06a80feb" to tk9.0.2
  • start a visual studio command prompt
  • cd c:\test\tcl9.0.2\win
  • nmake -f Makefile.vc
  • nmake -f Makefile.vc install INSTALLDIR=c:\test\tcl902
  • cd c:\test\tk9.0.2\tk
  • nmake -f Makefile.vc
  • nmake -f Makefile.vc install INSTALLDIR=c:\test\tcl902
  • try the wish in c:\test\tcl902\bin

Good luck, Harald


anonymous (claiming to be dhr) added on 2025-10-20 14:39:10:
Hi Harald,

> @dhr, are you able to test and confirm, that the patch is effective for you?

I would be happy to test it and confirm, but I don't know how to obtain the patched source/branch, and I don't know how to build Tcl/Tk from source on windows.

If there is a guide somewhere that explains what to do, let me know and I'll look into building and testing it, otherwise it's probably not worth your time/effort to teach me how to build Tcl/Tk on windows. Sorry for the trouble.

Thanks a lot Christopher and Harald for the work in investigating this issue.
Regards,
dhr

chrstphrchvz added on 2025-10-18 21:50:49:

For testing the near-360 degree behavior, I used the reporter's animated example with -extent 359.8. The animation should show a complete or almost-complete filled circle and not "flicker".

François' approach is closer to the desired behavior, where arcs with an extent near 0 degrees still draw something (a point or line), rather than draw nothing as my approach does. Although his approach has the same issue as my first approach where an extent just under 360 degrees may get treated as 0 degrees and not draw as expected, I think that is easy to fix. So for now I would propose François' approach combined with an adjustment to handle near-360 degree arcs properly; see [06a80feb].

Regarding the other issues in [1081603], I do not know whether it is worth trying to get the arc drawing on Windows to match X11 exactly. Maybe such microscopic differences should be accepted as a limitation of the Win32 Tk port or the GDI functions it relies on.


chrstphrchvz added on 2025-10-17 23:23:35:

I meant to check whether this issue is a duplicate, particularly given how long it has existed; apologies for not doing so earlier.

This appears to be the same issue described in the comment dated 2007-09-26 on [1081603], and for which François proposed a fix 8 years ago in [ed8e17cc]. I would want to look at his approach before proceeding.


oehhar added on 2025-10-16 08:11:21:

Christopher, thanks, great, I appreciate !

I would love some additional source code commenting, why we need this flag. I can do that, if you like.

Is there an example to test the "rounded 360°" case ?

Perhaps, test wizard Eric may comment on the test possibility. Sad, thant magic Francois is not here any more, we miss his detailed work.

@dhr, are you able to test and confirm, that the patch is effective for you?

I am in favor (as TCT member) to merge to main, core-9-branch and core-8-6-branch. IMHO, the patch is an improvement, what is great. If Christover is also in favor, it may be merged.

Thanks for all, Harald


chrstphrchvz added on 2025-10-15 19:41:24:

Harald, thanks for the review and creating the branch. Maybe an interactive test is possible for this issue, although I am not familiar with those.

As documented, the canvas arc items treat an extent of 360 degrees or more as the extent modulo 360 degrees, so it is not possible to specify 360 degrees exactly. However it is still possible to specify an amount like 359.8 degrees which may get rounded to 360 degrees by DrawOrFillArc(), so I have pushed a revised fix [32db5e81] which accounts for that.


oehhar added on 2025-10-15 08:47:16:

Christopher, thanks for the fix. It is now in commit [2c3275d0] starting branch [6051a9fc-win-arc-small].

For me, it is effective. Now, only a line is drawn for both examples (MS-Win 11 64bit, MS-VS2022 64 bit).

I have two questions:

  • may a test case be possible?
  • what happens, if I want to fill 360°? Does it still work? Don't we need an indication, if the two numbers got equal due to rounding or by intention?

Thanks for all, Harald


chrstphrchvz added on 2025-10-14 21:09:37:

A note for the reporter: consider using [tk windowingsystem] to check for X11/Win32/Aqua rather than $tcl_platform(os).

In DrawOrFillArc() (tkWinDraw.c), input angles are converted to radials. After rounding, it is possible for these radials to be identical, i.e. xstart == xend and ystart == yend. The problem is that passing identical radials to the Win32 GDI functions Arc(), Chord(), and Pie() causes them to draw 360 degrees, rather than 0 degrees as Tk seems to expect. Note: only the rectangular portion within the bounding box of an arc item is visible, and not necessarily all of the 360 degrees of drawing.

A naïve solution might be something like this, although I am not certain it is correct for XFillArc() usage other than canvas arc items:

--- win/tkWinDraw.c
+++ win/tkWinDraw.c
@@ -1261,7 +1261,9 @@
 
pen = SetUpGraphicsPort(gc); oldPen = SelectObject(dc, pen); - if (!fill) { + if ((xstart == xend) && (ystart == yend)) { + /* Do nothing. See bug [6051a9fc] */ + } else if (!fill) { /* * Note that this call will leave a gap of one pixel at the end of the * arc for thin arcs. We can't use ArcTo because it's only supported


oehhar added on 2025-10-14 07:21:52:

Thanks for the report. I can confirm, that the bug is in Tk 8.6.16 and Tk 9.0.2.

Attached is a screenshot of the first example, as the 2nd example is animated and hard to make a screen shot.

For me, it is also clear, that we need an antialiased version, as this looks outdated.

I also tested with undroidwish. It does not have the bug (see attached).

For those who want to understand the issue, please compare the undrowish and the windows screenshot.


anonymous added on 2025-10-13 21:18:34:

Here's another test script that might demonstrate the problem a bit more clearly:

package require Tk

canvas .c -width 200 -height 200 -background black
pack .c -expand 1 -fill both
pack [label .l -anchor w] -fill x
pack [label .l2 -text "Tk $tk_version"] -fill x

set itm [.c create arc 2 2 199 199 \
 -outline pink \
 -fill red \
 -extent 0.2]

wm title . "Testing: $tcl_platform(os)"

set start 0.1

proc animate {} {
 global start itm
 set start [expr {$start + 0.171671}]
 .c itemconfigure $itm -start $start
 .l configure -text $start
 after 17 animate
}

animate

I've also attached a screenshot of this test script running on Tcl/Tk 9.0 for windows (via wine, but the behaviour was identical on my friend's computer with windows 11), Tcl/Tk 8.6.12 on Linux, and a historical version of Tcl/Tk for comparison.

It seems like the windows version of Tk has had this bug since at least late 1996.


Attachments: