What is canvas ?
- Canvas is a geometry material thing like line, circle, rectangle etc.
- To draw a canvas like structure, many programming language like c, c++, python, java etc supports this.
rectangle-
Syntax-
canvas.create_rectangle(x1,y1,x2,y2,option,...)
-Here (x1,y1) and (x2,y2) are different ends of the rectangle.
program-
from tkinter import *
import random
#create a window screen
win=Tk()
win.geometry("500x400")
canvas=Canvas(win,bg="white",height=400,width=500)
canvas.place(x=0,y=0)
canvas.create_rectangle(30,30,150,150,fill="green")
canvas.create_rectangle(200,150,300,200,fill="blue")
canvas.create_rectangle(250,250,450,350)
#hold the screen
win.mainloop()