-
Notifications
You must be signed in to change notification settings - Fork 1
flip() or reflect()
Luke edited this page May 7, 2020
·
3 revisions
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.
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()
Copyright (C) 2020 Luke Zhang
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the conditions at https://github.com/Luke-zhang-04/CanvasPlus/blob/master/LICENSE.