When executing a python script (using Brython in a sandbox on codehs.com), I'm getting an extra white rectangle, left of the grid I'm outputting to the screen:
When inspecting the html, I can see where it is coming from:
Is there any way I can get rid of that white rectangle?
Here is my code so far:
from browser import document, html, window
# Create a canvas element and set its size
canvas = html.CANVAS(width=400, height=400)
document <= canvas
def create_grid(canvas):
# Get the canvas context
ctx = canvas.getContext('2d')
# Define cell size and line width
cell_size = 20
line_width = 1
# Draw grid lines
for x in range(0, 400, cell_size):
ctx.moveTo(x, 0)
ctx.lineTo(x, 400)
ctx.lineWidth = line_width
ctx.stroke()
for y in range(0, 400, cell_size):
ctx.moveTo(0, y)
ctx.lineTo(400, y)
ctx.lineWidth = line_width
ctx.stroke()
create_grid(canvas)