Skip to content

Commit

Permalink
SVG images are supported
Browse files Browse the repository at this point in the history
  • Loading branch information
jobtalle committed May 29, 2023
1 parent 5af17e2 commit 638a3dc
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions js/sdfMaker.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,24 +178,28 @@ export class SDFMaker {

if (item.kind === "file") {
const file = item.getAsFile();
console.log(file.type)
switch (file.type) {
case "image/png":
case "image/svg+xml":
const reader = new FileReader();

if (file.type === "image/png") {
const reader = new FileReader();
reader.onload = () => {
const image = new Image();

reader.onload = () => {
const image = new Image();
image.onload = () => {
this.#loadImage(file.name, image);
};

image.onload = () => {
this.#loadImage(file.name, image);
image.src = reader.result;
};

image.src = reader.result;
};
reader.readAsDataURL(file);

reader.readAsDataURL(file);
break;
default:
alert("Only .png files are supported");
}
else
alert("Only .png files are supported");
}
}

Expand Down

0 comments on commit 638a3dc

Please sign in to comment.