Tk Source Code

View Ticket
Login
Ticket UUID: f3e40e98d4b08d901fd53fe2ba2e0d2f2e83f80c
Title: outlinestipple not working
Type: Bug Version: 8.6
Submitter: sergiol Created on: 2017-11-04 23:10:14
Subsystem: 05. Canvas Items Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2019-12-05 07:04:33
Resolution: None Closed By: nobody
    Closed on: 2017-12-13 23:32:47
Description:
May be the bug is resolution specific or Windows specific.
OS is Windows 10; res is 1920x1080.

The -outlinestipple option does not effect. Some code:

<verbatim>
package require Tk
grid [canvas .c -bg #fcfcfc -width 640 -height 640]
.c create oval 8 8 600 600 -width 48 -outline yellow -outlinestipple gray25
</verbatim>

I also tried with other stipples than gray25

I explored the bug with avl42 on the Tclers chat today, where he tried the same code in a Linux machine with a lower resolution and it works fine there.

See [http://tclers.tk/conferences/tcl/2017-11-04.tcl|chat log line 771 ff].

Seems to be an already known bug:

[220787fff] — Stipple patterns don't work in arc/oval items on Windows/Mac

[220059fff] — -outline stipple option doesn't work with create rectangle

[220058fff] — Canvas -stipple and -outline stipple options have no effect with $w create oval

<verbatim>
tcl_platform(byteOrder)     = littleEndian
tcl_platform(machine)       = amd64
tcl_platform(os)            = Windows NT
tcl_platform(osVersion)     = 10.0
tcl_platform(pathSeparator) = ;
tcl_platform(platform)      = windows
tcl_platform(pointerSize)   = 8
tcl_platform(threaded)      = 1
tcl_platform(user)          = ...
tcl_platform(wordSize)      = 4
</verbatim>
User Comments: sergiol added on 2017-12-19 01:20:24:

Linux rendering of fvogel's comment case 3:



Thanks, aspect.


sergiol added on 2017-12-17 02:09:32:
After my change to implement oval inner stipples, I noted:

On the following script it is evident an artifact line at the right:

grid [canvas .c -bg #fcfcfc -width 640 -height 640]
.c create oval 8 8 600 600 -width 48 -fill red -stipple error

I tweaked it in Visual Studio to force it to pass in 

		if (gc->arc_mode == ArcChord) {
			Chord(dc, x, y, (int)(x + width + 1), (int)(y + height + 1),
				xstart, ystart, xend, yend);
		}


instead of the else, which it is where it would pass. 


The result was good, that artifact line disappeared. Tried to append `-style chord` to line that creates the oval, but received error message `unknown option "-style"` — seems it is only for arcs.

Should we change it for ovals to be always `ArcChord` ? I don't know the consequences on non Windows platforms.

sergiol added on 2017-12-17 01:49:45:
Please forget my previous comment; it don't really fix the artifact.

SORRY!

sergiol added on 2017-12-17 00:53:24:


To fix the artefact at circle's right on following code:

canvas .c -bg white -width 200 -height 200; pack .c -expand yes -fill both
.c create rect 100 0 200 200 -fill yellow -width 0
.c create oval 50 50 150 150 -outlinestipple gray12 -outline blue -width 50

just append at line 1294 of

		SetBrushOrgEx(dc, gc->ts_x_origin, gc->ts_y_origin, NULL);

Didn't attach file because I want this fix entering on a different commit than previous.

sergiol added on 2017-12-17 00:43:09:
My last attachment: Support inner oval stipple.

Test case:

grid [canvas .c -bg #fcfcfc -width 640 -height 640]
.c create oval 8 8 600 600 -width 48 -fill yellow -stipple error

fvogel added on 2017-12-16 15:40:44:

> What looks strange is that -outlinestipple gray25 looks dark to me, and -outlinestipple gray75 looks lighter. I would have expected the opposite. Also, -outlinestipple gray25 looks quite different on Linux and Windows (again, win is much darker).

My commit [5dcc9460] fixes this.

Then I have propagated the fix to make -outlinestipple work with canvas rectangle items, see [5ecb5f35].

What I have noticed is that [aa0a19ae84] (that is: your original patch) breaks rendering of polygons (see case 3 below).

Also, arcs are not yet fully correct, see case 1b below.

Here is what I use for testing:

# case 1a: ovals
package require Tk
grid [canvas .c -bg #fcfcfc -width 640 -height 640]
.c create oval 8 8 600 600 -width 48 -outline yellow -outlinestipple gray25
.c itemconf 1 -outlinestipple gray75

# case 1b: arcs
package require Tk
grid [canvas .c -bg #fcfcfc -width 640 -height 640]
.c create arc 8 8 600 600 -width 48 -outline yellow -outlinestipple gray25
.c itemconf 1 -outlinestipple gray75

# case 2: rectangles
package require Tk
grid [canvas .c -bg #fcfcfc -width 640 -height 640]
.c create rectangle 8 8 600 600 -width 48 -outline yellow -outlinestipple gray25
.c itemconf 1 -outlinestipple gray75

# case 3: polygons
package require Tk
grid [canvas .c -bg #fcfcfc -width 640 -height 640]
.c create polygon 8 8 100 200 300 20 600 600 -width 48 -outline yellow -outlinestipple gray25
.c itemconf 1 -outlinestipple gray75


fvogel added on 2017-12-15 07:24:08:

Also I have fixed the code style, see [6cdfe5cb39].

Please respect the Tcl/Tk Engineering Manual.


fvogel added on 2017-12-15 07:18:28:

Looks better indeed. I have committed this in [194593c30e].

What looks strange is that -outlinestipple gray25 looks dark to me, and -outlinestipple gray75 looks lighter. I would have expected the opposite. Also, -outlinestipple gray25 looks wuite different on Linux and Windows (again, win is much darker).


sergiol added on 2017-12-14 23:16:44:

I edited the file again and now I got a pattern like

on Windows.

File is attached. Is this acceptable?


fvogel added on 2017-12-14 07:14:38:
sergiol, this bug is not fixed, please don't close it.

You have provided a beginning of a fix, but here is what remains to be done before closing the bug:

- honor the specified -outline color (or be convincing that it's impossible, and in such a case this needs to be documented in the man page)

- fix the macOS case, rendering currently ignores the -outlinestipple option

- review the man page to clarify any remaining ambiguities about what is supported or not on what platform

- think about adding test cases testing the newly implemented feature (not sure it's possible, but needs to be analyzed)

- merge the bugfix branch into the releasable branches

Only when all the above will be done the bug can be closed. I'm reopening in the meantime.

sergiol added on 2017-12-13 20:33:36:

How it looks in a Linux system:


How it looks in a Windows system after last fix:



It seems Windows drawing is not yet completely correct, as outlinestipple colour parameter should be considered!


sergiol added on 2017-12-12 22:19:02:

Confirmed on LOGBRUSH structure documentation:
"lbColor
Specifies the color in which the brush is to be drawn. If lbStyle is the BS_HOLLOW or BS_PATTERN style, lbColor is ignored."
So, or I can do it the way I was thinking or I must do it another way!


sergiol added on 2017-12-12 20:56:18:
I tried to override the `lbColor` with the colour with the color coming from `gc->foreground` after, but it did not produce any effect, maybe it is not supported or I am doing something wrong!

fvogel added on 2017-12-12 20:29:47:

Patch committed in a bugfix branch for easier analysis, see [aa0a19ae84].

First thing I notice is that the patch indeed does stippling, however it does not honor the yellow color (from the example given in the original report). Is this expected?


fvogel added on 2017-12-12 20:21:00:
OK, will review.

(I'm attaching your file here so that it does not get lost).

sergiol added on 2017-12-12 12:25:12:
I think I discovered how to fix the problem of -outlinestipple not working for rectangle and ovals when creating them on Windows. The fix was done on version 8.6.7: 
File is on https://files.fm/u/fsxx66aa
As it will be very first contribution on the Tcl/Tk own's source code, I am not so sure and I would like to ask for code review!

Attachments: