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.
Line-
Syntax-
canvas.create_line(x1,y1,x2,y2,option,...)
program-
from tkinter import *
#create a window screen
win=Tk()
win.geometry("500x400")
canvas=Canvas(win,bg="white",height=400,width=500)
canvas.place(x=0,y=0)
#create three lines at different x,y coordinate
l=canvas.create_line(100,90,100,325,fill="red",width=3)
l=canvas.create_line(10,40,350,200,fill="green",width=3)
l=canvas.create_line(200,300,450,300,fill="blue",width=3)
#hold the screen
win.mainloop()
output-
-In this program, we firslty create a canvas window inside the window screen by using canvas=Canvas(win).
-Then we create a three lines with differnt orientation with different colours and with width of 3.