MCPcopy Index your code
hub / github.com/pyscript/pyscript / draw

Method draw

core/src/stdlib/pyscript/web.py:1202–1218  ·  view source on GitHub ↗

Draw a 2d image source (`what`) onto the canvas. Optionally scale to `width` and `height`. Accepts canvas image sources: `HTMLImageElement`, `SVGImageElement`, `HTMLVideoElement`, `HTMLCanvasElement`, `ImageBitmap`, `OffscreenCanvas`, or `VideoFrame`.

(self, what, width=None, height=None)

Source from the content-addressed store, hash-verified

1200 download_link._dom_element.click()
1201
1202 def draw(self, what, width=None, height=None):
1203 """
1204 Draw a 2d image source (`what`) onto the canvas. Optionally scale to
1205 `width` and `height`.
1206
1207 Accepts canvas image sources: `HTMLImageElement`, `SVGImageElement`,
1208 `HTMLVideoElement`, `HTMLCanvasElement`, `ImageBitmap`,
1209 `OffscreenCanvas`, or `VideoFrame`.
1210 """
1211 if isinstance(what, Element):
1212 what = what._dom_element
1213
1214 ctx = self._dom_element.getContext("2d")
1215 if width or height:
1216 ctx.drawImage(what, 0, 0, width, height)
1217 else:
1218 ctx.drawImage(what, 0, 0)
1219
1220
1221class video(ContainerElement):

Callers 2

snapMethod · 0.80
mainFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected