-
Notifications
You must be signed in to change notification settings - Fork 1
create_round_rectangle()
Luke edited this page Apr 12, 2020
·
4 revisions
There's no easy way to create a rectangle with rounded corners. This method makes it easy.
from numbers import Real
def create_round_rectangle(self, x1: Real, y1: Real, x2: Real, y2: Real, radius: Real = 25, **kwargs) -> intAlso, making a rectangle with 4 circles is quite laborious and is something to avoid.
from tkinter import Tk
from CanvasPlus import CanvasPlus
root = Tk()
canvas = CanvasPlus(root, width=800, height=800, background = "white")
canvas.pack()
canvas.create_round_rectangle(400, 400, 500, 500, radius = 75, fill = "blue", outline = "orange", width = 5)
canvas.create_round_rectangle(100, 250, 300, 410, radius = 25, fill = "#f4f4f4", outline = "black", width = 3)
canvas.create_round_rectangle(500, 600, 700, 800, radius = 10, fill = "red", width = 0)
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.