canvas.create_rectangle code example
Example 1: rectangle in tkinter
from tkinter import *
root = Tk()
c = Canvas(root)
c.pack()
c.create_rectangle(100, 100, 200, 200)
root.mainloop()
Example 2: draw rectangle on canvas javascript
//Assuming you have canvas and context (ctx) set up:
ctx.fillStyle = "(enter color)";
ctx.fillRect(x, y, width, height);
//to set up canvas and context:
var canvas = document.getElementById("(enter canvas's id)");
var ctx = canvas.getContext("2d");