Tk Source Code

View Ticket
Login
Ticket UUID: 220895
Title: Canvas inconsistantly draws lines on Linux/UNIX
Type: Bug Version: 8.3, 8.6.18, 9.0.5, 9.1.0
Submitter: welch Created on: 2000-11-01 01:30:48
Subsystem: 05. Canvas Items Assigned To: aku
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2026-10-30 20:30:02
Resolution: Fixed Closed By: nemethi
    Closed on: 2026-10-30 20:30:02
Description:
OriginalBugID: 4195 Bug
Version: 8.3
SubmitDate: '2000-02-16'
LastModified: '2000-02-16'
Severity: MED
Status: UnAssn
Submitter: ericm
ChangedBy: ericm
OS: Linux-Red Hat


I want to create a line like this in the canvas (# indicates a
colored pixel):

  #
  #
  #
 #
#

If I draw it from the bottom to the top, ala

.c create line 50 50 52 48 52 30

It omits one pixel at the top of the diagonal, giving me this:

  #
  #

 #
#

If I draw it from the top, it draws correctly:

.c create line 52 30 52 48 50 50

These two commands should produce visually indistinguishable
lines.  The first command should not omit the pixel at the top
of the diagonal.

- eric
User Comments: nemethi (claiming to be Csaba Nemethi) added on 2026-10-30 20:30:02:

Merged by Jan into main and core-9-0-branch by commits [53abc363] and [1152f5a2]. Backported to core-8-6-branch by commit [2b9c2189]. Closing the ticket.


serhiy.storchaka added on 2026-10-22 22:49:16:

Re-tested on Windows 11 with today's main: the last point of a thin line is still not drawn, so each of the eight lines of my test differs from the same line with its points reversed. Branch win-thin-line-endpoints fixes all eight, and canvas.test and canvLine.test pass with it.


serhiy.storchaka added on 2026-09-22 08:38:57:

On X11 this is no longer reproducible: the X server draws thin lines independently of the order of their points (an end point of a line of width 1 is drawn if and only if it is the left or top end of its segment), so both lines give the same pixels.

On Windows the bug still existed in a different form: GDI does not draw the last point of a polyline drawn with a cosmetic pen, whichever end that is, so the two lines differed and each of them lacked one end point. Fixed in [38ab656ced] (branch win-thin-line-endpoints): the end points of lines of width 1 are now drawn as on X11. Test canvas-28.1 checks that eight thin lines give the same pixels as with their points reversed.

Lines of width 0 are not changed. X11 draws both of their end points, Windows omits the last one, and Ttk works around it with WIN32_XDRAWLINE_HACK (most recently for [8b725d6bde]); the winnative theme has the GDI rule built into its tab coordinates. The right fix is to draw the last point of width-0 lines (and of thin arcs, which have the same problem) on Windows and to remove these workarounds, but that is a separate, larger change which needs a visual comparison of all themes with X11.


pcaffin added on 2008-03-24 13:51:57:
Logged In: YES 
user_id=2029956
Originator: NO

Tested with:

########################
pack [canvas .c]
# Broken
.c create line 50 50 52 48 52 30
# Works
.c create line 152 130 152 148 150 150
########################

The only difference being a 1 prepended to all numbers in the second example, to make it easier to view the two side by side in the same canvas.

I can confirm the effect still exists in Tk 8.5.2 (teapot) on Linux. A similar but different effect appears on Windows XP. It doesn't act as expected on either platform. I haven't tested on Mac.