Skip to content

Commit

Permalink
Fix file paths of password images
Browse files Browse the repository at this point in the history
  • Loading branch information
Karthik99999 committed Feb 20, 2024
1 parent 7683388 commit 51bff48
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/routes/(rtdx)/PasswordImage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
export let type: string;
let canvas: HTMLCanvasElement;
const loadImage = (src: string) => {
const loadImage = (name: string) => {
return new Promise<HTMLImageElement>((resolve, reject) => {
const img = new Image();
img.onload = () => resolve(img);
img.onerror = reject;
img.src = `${base}/${src}`;
img.src = `${base}/rtdx-password/${name}.png`;
});
};
onMount(async () => {
const ctx = canvas.getContext('2d')!;
const background = await loadImage(`/rtdx-password/${type}.png`);
const background = await loadImage(type);
ctx.drawImage(background, 0, 0, 912, 233);
const drawCharacter = async (char: string, x: number, y: number) => {
Expand All @@ -29,12 +29,12 @@
e: 'emerald',
s: 'star',
};
const symbol = await loadImage(`/rtdx-password/${symbols[char.charAt(1)]}.png`);
const symbol = await loadImage(symbols[char.charAt(1)]);
ctx.drawImage(symbol, x, y, 40, 40);
const xc = x + 10;
const yc = y + 10;
const character = await loadImage(`/rtdx-password/${char.charAt(0)}.png`);
const character = await loadImage(char.charAt(0));
ctx.drawImage(character, xc, yc, 20, 20);
};
Expand Down

0 comments on commit 51bff48

Please sign in to comment.