Skip to content

to_polygon()

Luke edited this page Apr 12, 2020 · 3 revisions

CanvasPlus.to_polygon(), or CanvasPlus.poly()

Since a rectangle can't be properly rotated, it must be converted into a polygon first. This way, it can be rotated freely.

def to_polygon(self, obj:int) -> int

Also,

poly = to_polygon

Example:

from tkinter import Tk
from canvasplus import CanvasPlus
root = Tk()

canvas = CanvasPlus(root, width=800, height=800, background = "white")
canvas.pack()

polyRect = canvas.create_rectangle(100, 100, 200, 200, fill="#f7a8c6", width=0)
polyRect = canvas.poly(polyRect)
canvas.rotate(polyRect, 150, 150, 6, unit = "r")

rect = canvas.create_rectangle(100, 100, 200, 200, fill="blue", width=0)
canvas.rotate(rect, 150, 150, 6, unit = "r")

canvas.update()
canvas.mainloop()

Screen Shot 2020-03-30 at 5 48 41 PM

Clone this wiki locally