Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Enhance draw method to include x and y coordinates
Added x and y parameters to the draw method to specify the position for drawing the image.
  • Loading branch information
Ign555 authored May 8, 2026
commit 7a8cd2a6955467e537008b87e881eb84904b8e60
6 changes: 3 additions & 3 deletions core/src/stdlib/pyscript/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ def download(self, filename="snapped.png"):
self.append(download_link)
download_link._dom_element.click()

def draw(self, what, width=None, height=None):
def draw(self, what, width=None, height=None, x=0, y=0):
"""
Draw a 2d image source (`what`) onto the canvas. Optionally scale to
`width` and `height`.
Expand All @@ -1213,9 +1213,9 @@ def draw(self, what, width=None, height=None):

ctx = self._dom_element.getContext("2d")
if width or height:
ctx.drawImage(what, 0, 0, width, height)
ctx.drawImage(what, x, y, width, height)
else:
ctx.drawImage(what, 0, 0)
ctx.drawImage(what, x, y)


class video(ContainerElement):
Expand Down