diff options
author | Eric Bailey <git@esb.lol> | 2024-09-10 16:20:19 -0500 |
---|---|---|
committer | Eric Bailey <git@esb.lol> | 2024-09-11 19:58:16 -0500 |
commit | eaf0081623154df995e81f2ae430a723539df800 (patch) | |
tree | 704a27f675e28ac81151a92404cf7889ebb2cd97 /src/lib/canvas.ts | |
parent | 3c8b3b47823475b93a92dcf82a4cabbda625c323 (diff) | |
download | voidsky-eaf0081623154df995e81f2ae430a723539df800.tar.zst |
WIP, avi not working on web
Diffstat (limited to 'src/lib/canvas.ts')
-rw-r--r-- | src/lib/canvas.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/canvas.ts b/src/lib/canvas.ts new file mode 100644 index 000000000..760c0e67f --- /dev/null +++ b/src/lib/canvas.ts @@ -0,0 +1,15 @@ +export const getCanvas = (base64: string): Promise<HTMLCanvasElement> => { + return new Promise(resolve => { + const image = new Image() + image.onload = () => { + const canvas = document.createElement('canvas') + canvas.width = image.width + canvas.height = image.height + + const ctx = canvas.getContext('2d') + ctx?.drawImage(image, 0, 0) + resolve(canvas) + } + image.src = base64 + }) +} |