This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Python Turtle is not filling alternate overlapping areas of a shape with same color
Type: Stage: resolved
Components: Documentation Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, gregorlingl, lijose, miss-islington, terry.reedy, willingc
Priority: normal Keywords: patch

Created on 2020-01-20 05:14 by lijose, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 18223 merged terry.reedy, 2020-01-27 23:21
PR 18224 merged miss-islington, 2020-01-27 23:41
PR 18225 merged miss-islington, 2020-01-27 23:41
Messages (5)
msg360290 - (view) Author: Lijo (lijose) Date: 2020-01-20 05:14
Alternate overlapping areas of shape are not getting filled with same color. But instead its white.
Reproducible code

from turtle import *
color('black', 'yellow')    
begin_fill()
circle(40)
circle(60)
circle(80)
end_fill()

Generated image ubuntu@python3.7.4
https://ibb.co/jG0bCBz

Raised a stackoverflow question
https://stackoverflow.com/questions/59811915/python-turtle-is-not-filling-alternate-overlapping-areas-of-a-shape-with-same-co
msg360660 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-01-24 23:22
Your SO question is essentially a duplicate.  As I answered there, the graphics systems of Unix and Windows, used by tk and hence tkinter, handle filling of self-intersecting polygons differently.  On Windows, if one draws a line from the outside to a particular region without going through an intersection, each line crossing toggles 'fill', starting with 'off' in the outside.

The rule seems to be reversed for overlapping items, such as circles.  On Windows, all three circles are yellow, whereas on macOS, the 60 circle is white, even if drawn last!

So, no bug.  The best we can do is document 'filling' for turtle.  Our tkinter doc does not include tk widgets, in particular Canvas, and we cannot edit external sources.

What happens with multiple fill colors?  Blended, or last wins?

# 1 fill block
from turtle import *
color('black', 'yellow')    
begin_fill()
circle(40)
color('black', 'red')    
circle(60)
color('black', 'blue')    
circle(80)
end_fill()

On Windows, 3 circles drawn, then all filled with blue.  The same is true if the circle order is reversed.

# multiple fill blocks
from turtle import *
color('black', 'yellow')    
begin_fill()
circle(40)
end_fill()
color('black', 'red')    
begin_fill()
circle(60)
end_fill()
color('black', 'blue')    
begin_fill()
circle(80)
end_fill()

On Windows, each circle fills with its color after it is drawn.  Same final result.  It is different if drawing order is reversed.  The rule seems to be: lines are drawn with the current line color; fill is done at the end of each fill block with the current (last) fill color.
msg360823 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-01-27 23:41
New changeset 2824c45a0a020f12f27da7e7162e8636c21bf869 by Terry Jan Reedy in branch 'master':
bpo-39392: Turtle overlap fill depends on OS (#18223)
https://github.com/python/cpython/commit/2824c45a0a020f12f27da7e7162e8636c21bf869
msg360824 - (view) Author: miss-islington (miss-islington) Date: 2020-01-27 23:46
New changeset 005b0596326cf1b4f17e8d38bfc3887d4486e564 by Miss Islington (bot) in branch '3.7':
bpo-39392: Turtle overlap fill depends on OS (GH-18223)
https://github.com/python/cpython/commit/005b0596326cf1b4f17e8d38bfc3887d4486e564
msg360826 - (view) Author: miss-islington (miss-islington) Date: 2020-01-27 23:47
New changeset b487a8ed5bd267d62a05c3cab7def6b1f36999ea by Miss Islington (bot) in branch '3.8':
bpo-39392: Turtle overlap fill depends on OS (GH-18223)
https://github.com/python/cpython/commit/b487a8ed5bd267d62a05c3cab7def6b1f36999ea
History
Date User Action Args
2022-04-11 14:59:25adminsetgithub: 83573
2020-01-27 23:48:05terry.reedysetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-01-27 23:47:12miss-islingtonsetmessages: + msg360826
2020-01-27 23:46:31miss-islingtonsetnosy: + miss-islington
messages: + msg360824
2020-01-27 23:41:36miss-islingtonsetpull_requests: + pull_request17605
2020-01-27 23:41:31miss-islingtonsetpull_requests: + pull_request17604
2020-01-27 23:41:24terry.reedysetmessages: + msg360823
2020-01-27 23:21:06terry.reedysetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request17603
2020-01-24 23:22:10terry.reedysetassignee: docs@python
type: behavior ->
components: + Documentation, - Tkinter
versions: + Python 3.8, Python 3.9
nosy: + docs@python, terry.reedy

messages: + msg360660
stage: needs patch
2020-01-20 22:43:52ned.deilysetnosy: + gregorlingl, willingc
2020-01-20 05:14:23lijosecreate