龟图 begin_fill() 函数在 MAC 上无法正常工作

Turtle graphic begin_fill() function does not work correctly on MAC

我正在尝试使用模块 turtle 绘制一颗 "Yellow" 星。当我 运行 我的程序在 Windows OS 上时,它工作正常。但是,当我在 macOS 上 运行 时,图形是错误的。 Result on macOS

Result on Windows OS

import turtle
# Setup a screen and a turtle
win = turtle.Screen()
bob = turtle.Turtle()
# set the background color for the flag
win.bgcolor("red")
# Draw a star
# change the turtle color to yellow 
bob.color("yellow")
# to center we have to go backward for half of a side length
bob.penup()
bob.back(100)
bob.pendown()
bob.begin_fill()
for i in range(5):
    bob.forward(200)
    bob.right(144)
bob.end_fill()
win.exitonclick()

这不是乌龟问题,而是底层 tkinter 库的问题。当涉及交叉线时,两个操作系统上的填充是不同的。解决方法是画星星不画交叉线:

from turtle import Screen, Turtle

win = Screen()
win.bgcolor("red")

bob = Turtle()
bob.color("yellow")

bob.penup()
bob.goto(24.5, 33.1)
bob.pendown()

bob.begin_fill()

for i in range(5):
    bob.forward(80)
    bob.right(144)
    bob.forward(80)
    bob.left(72)

bob.end_fill()
bob.hideturtle()

win.exitonclick()

这在两种实现上看起来应该是一样的: