Skip to content
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