I managed to draw a circle at least!
s = 256

canvas = torch.zeros([1, 1, s, s])

ss = torch.linspace(0, 1, s)
x, y = torch.meshgrid(ss, ss)

px = 0.5
py = 0.5
w = 0.5
h = 0.5

image = 1 - 2*(((x - px)**2) / w**2 + ((y - py)**2) / h**2)
image2 = image.clamp(0, 1)
canvas[0, 0] = image2

Tomorrow it’s time for rectangles.