From 7a8cd2a6955467e537008b87e881eb84904b8e60 Mon Sep 17 00:00:00 2001 From: Ign555 <88973001+Ign555@users.noreply.github.com> Date: Fri, 8 May 2026 22:21:17 +0200 Subject: [PATCH] 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. --- core/src/stdlib/pyscript/web.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/stdlib/pyscript/web.py b/core/src/stdlib/pyscript/web.py index 3cafa8ceb9a..f433211d13a 100644 --- a/core/src/stdlib/pyscript/web.py +++ b/core/src/stdlib/pyscript/web.py @@ -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`. @@ -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):