龟本身绘制图形 [英] Turtle graphics drawing over itself
问题描述
for y在范围内(高度):
turtle.pendown()
为范围(宽度)x:
detLand(y,x)#设置颜色,工作正常
turtle.setx(x)
turtle.sety(y)
turtle.penup()
我认为这很容易,但它仍然在顶层我的线。
我相信问题在于您意外地在仰泳上画画。试试这个:
for y在范围内(高度):
turtle.sety(y)
turtle.pendown()
为范围(宽度)x:
detLand(y,x)
turtle.setx(x)
turtle.penup()
turtle.setx(0)
我相信你的问题是这种分裂:
turtle.setx(x)
turtle.sety(y)
想想在行尾会发生什么,您只需设置Y,然后绕过X = 0并在Y正确定位之前画出刚完成的线。
This should be a very simple question, however, it is proving difficult for me. I'm rather new to turtle graphics, and so, I am trying to get a simple drawing done. My turtle will draw a row, pick the pen up, move up one pixel, place the pen down, and keep drawing. Here's my code so far:
for y in range(height):
turtle.pendown()
for x in range(width):
detLand(y, x) # Set the color, works just fine
turtle.setx(x)
turtle.sety(y)
turtle.penup()
I figured this would be easy, however, it's still drawing over top of my lines.
I believe the problem is that you're accidentally drawing on the backstroke. Try this instead:
for y in range(height):
turtle.sety(y)
turtle.pendown()
for x in range(width):
detLand(y, x)
turtle.setx(x)
turtle.penup()
turtle.setx(0)
I believe your problem is this schism:
turtle.setx(x)
turtle.sety(y)
Think about what happens at end of line, you just set Y and then you come around with X = 0 and over draw the line you just finished before Y gets positioned correctly.
这篇关于龟本身绘制图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!