Каждая кнопка внизу должна рисовать заданные фигуры с параметрами справа.Треугольник и квадрат нарисованы правильно, но при попытке нарисовать пятиугольник он не касается кончика и не переместится вправо
exampleImage
heresмой код:
def drawTriangle(self):
color = self.favorite.get()
thickness = int(self.widthEntry.get())
length = int(self.lengthEntry.get())
self.canvas.create_line(self.x, self.y, self.x - (length/2), self.y + length, fill = color, width = thickness)
self.x -= length/2
self.y += length
self.canvas.create_line(self.x, self.y, self.x + length, self.y, fill = color, width = thickness)
self.x += length
self.canvas.create_line(self.x, self.y, self.x - (length/2), self.y - length, fill = color, width = thickness)
self.x -= length/2
self.y -= length
self.x += 70
def drawSquare(self):
color = self.favorite.get()
thickness = int(self.widthEntry.get())
length = int(self.lengthEntry.get())
self.canvas.create_line(self.x, self.y, self.x + length, self.y, fill = color, width = thickness)
self.x += length
self.canvas.create_line(self.x, self.y, self.x, self.y + length, fill = color, width = thickness)
self.y += length
self.canvas.create_line(self.x, self.y, self.x - length, self.y, fill = color, width = thickness)
self.x -= length
self.canvas.create_line(self.x, self.y, self.x, self.y - length, fill = color, width = thickness)
self.y -= length
self.x += 70
def drawPentagon(self):
color = self.favorite.get()
thickness = int(self.widthEntry.get())
length = int(self.lengthEntry.get())
self.canvas.create_line(self.x, self.y, self.x - (length/2), self.y + (length/3), fill = color, width = thickness)
self.x -= length/2
self.y += length/3
self.canvas.create_line(self.x, self.y, self.x + (length/5), self.y + (length*2/3), fill = color, width = thickness)
self.x += length/5
self.y += length*2/3
self.canvas.create_line(self.x, self.y, self.x + (length*4/5), self.y, fill = color, width = thickness)
self.x += length*4/5
self.canvas.create_line(self.x, self.y, self.x + (length/5), self.y - (length*2/3), fill = color, width = thickness)
self.x += length/5
self.y -= length*2/3
self.canvas.create_line(self.x, self.y, self.x - (length/2), self.y - (length/3), fill = color, width = thickness)
self.x -= length/2
self.y -= length/3
self.x += 70
РЕДАКТИРОВАТЬ: Wow я так глуп.Была простая математическая задача.Спасибо за помощь!Я обязательно сделаю больше отладки, прежде чем писать здесь.