I wanted to create a type of "grid" using turtle in python but when I start the program the parts of the drawing had a sort of broken line like this: Glitchy part
This is the full image: Full drawing
I don't know is this a glitch or something wrong in my code but this is what I did:
for column in range(5):
penup()
goto(-207.5, (325 - (column * 110)))
color('darkgray')
begin_fill()
for row in range(5):
pendown()
for square in range(4):
forward(75)
right(90)
penup()
forward(85)
end_fill()
This program is drawing 5 cubes in a column and the whole drawing has 5 colums. My problem is that certant cubes get drawn wrong like I showed in first image and usualy the first row is drawn completly wrong(with broken lines in cubes) like in second image. Is this a glitch or did I do something wrong? Can I fix it? Thanks for all answers!
The problem appears to be -207.5. Make that a whole number.
I also removed some redundant code such as drawing the same square 5 times and used instance mode instead of the error-prone from turtle import *
wildcard import that pollutes the namespace.
from turtle import Screen, Turtle
t = Turtle()
t.color("darkgray")
t.penup()
for column in range(5):
t.goto(-207, 325 - column * 110)
t.pendown()
t.begin_fill()
for _ in range(4):
t.forward(75)
t.right(90)
t.penup()
t.end_fill()
Screen().exitonclick()