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)
| 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 | |
| 1221 | class video(ContainerElement): |