【发布时间】:2015-11-05 08:20:37
【问题描述】:
我正在使用 Python 的 turtle 模块和以下代码绘制一个相当简单的形状:
import turtle
turtle.color('black', '#fef00e')
turtle.begin_fill()
turtle.left(180)
turtle.forward(100)
for i in range(5):
turtle.right(90)
turtle.forward(100+50*i)
turtle.end_fill()
turtle.done()
奇怪的是,这会在 Windows(左)和我尝试过的所有其他操作系统(Ubuntu、Arch、OSX)上产生两种不同的结果。具有偶数重叠填充的区域仍会在 Windows 上填充,但对于其他区域则再次空白。谁能解释一下这是什么原因,是否有任何影响它的方法?这种行为如此不一致似乎很奇怪。
这似乎也是一种设计选择;对我来说,这两个版本中的哪一个是“正确”版本并不是很明显。
【问题讨论】:
-
他们可能出于某种原因使用了不同的填充规则。左边是non-zero winding rule,右边是even-odd rule。
标签: python turtle-graphics graph-coloring