Skip to content

flip() or reflect()

Luke edited this page May 7, 2020 · 3 revisions

CanvasPlus.flip() or CanvasPlus.reflect()

Allows you to easily flip a tkinter canvas element along a line.

from numbers import Real
from typing import Union
def flip(self, tagOrId: Union[int, str], **eqn: Dict) -> Tuple[Union[float, int]]

Flips a tagorid along equation of a line. Returns new coords.

Example:

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

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

#flip example
a = canvas.create_polygon(500, 10, 500, 20, 550, 25, 600, 20, 600, 10, fill = "yellow", outline = "black")
aPrime, aDoublePrime = canvas.clone(a), canvas.clone(a)
canvas.flip(aPrime, m = .5, b = -200)
canvas.flip(aDoublePrime, y = 100)

aTriplePrime = canvas.clone(aDoublePrime)
canvas.flip(aTriplePrime, x = 400)

canvas.update()
canvas.mainloop()

Screen Shot 2020-04-12 at 5 32 38 PM

Clone this wiki locally