Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use CanvasImageSource instead of HTMLImageElement #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class Perspective {
// Context for transformed image
private ctxt: CanvasRenderingContext2D;

constructor(ctxd: CanvasRenderingContext2D, image: HTMLImageElement) {
constructor(ctxd: CanvasRenderingContext2D, image: CanvasImageSource) {
// check the arguments
if (!ctxd || !ctxd.strokeStyle) {
return;
Expand All @@ -53,8 +53,8 @@ export default class Perspective {
}
// prepare a <canvas> for the image
let cvso = document.createElement("canvas");
cvso.width = Math.round(image.width);
cvso.height = Math.round(image.height);
cvso.width = Math.round(typeof image.width === "number" ? image.width : image.width.baseVal.value);
cvso.height = Math.round(typeof image.height === "number" ? image.height : image.height.baseVal.value);
let ctxo = cvso.getContext("2d");
ctxo.drawImage(image, 0, 0, cvso.width, cvso.height);
// prepare a <canvas> for the transformed image
Expand Down