@@ -20,9 +20,9 @@ async function setup() {
20
20
// Use async/await with Promise.all to load all three images at once
21
21
// This waits until ALL images are loaded before continuing
22
22
[ img1 , img2 , img3 ] = await Promise . all ( [
23
- loadImageAsync ( 'https://picsum.photos/100/100?random=1' ) , // Replace the image links with user wanted images.
24
- loadImageAsync ( 'https://picsum.photos/100/100?random=2' ) ,
25
- loadImageAsync ( 'https://picsum.photos/100/100?random=3' )
23
+ loadImage ( 'https://picsum.photos/100/100?random=1' ) , // Replace the image links with user wanted images.
24
+ loadImage ( 'https://picsum.photos/100/100?random=2' ) ,
25
+ loadImage ( 'https://picsum.photos/100/100?random=3' )
26
26
] ) ;
27
27
28
28
// Once all images are ready, draw them on the canvas
@@ -35,12 +35,3 @@ async function setup() {
35
35
text ( "All images loaded!" , width / 2 , 50 ) ;
36
36
}
37
37
38
- // Helper function to load images using a Promise
39
- // Makes loadImage compatible with async/await style
40
- function loadImageAsync ( url ) {
41
- return new Promise ( ( resolve , reject ) => {
42
- // Try to load the image from the given URL.
43
- //If successful, resolve the promise with the image. If it fails, reject with the error.
44
- loadImage ( url , img => resolve ( img ) , err => reject ( err ) ) ;
45
- } ) ;
46
- }
0 commit comments