-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathloadImage.js
More file actions
32 lines (24 loc) · 833 Bytes
/
loadImage.js
File metadata and controls
32 lines (24 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
setup = function() {
var body = document.getElementById('body');
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
body.appendChild(canvas);
// Create a new image with:
// a 'src' attribute of "/media/img/gamedev/ralphyrobot.png"
// and an 'onload' attribute of onImageLoad
// YOUR CODE HERE
img = new Image();
img.onload = onImageLoad;
img.src = "/media/img/gamedev/ralphyrobot.png";
};
onImageLoad = function(){
// Use the console.log function to print a statement to the browser console.
// This will print once the image has been downloaded.
// YOUR CODE HERE
console.log("image dome!");
};
// We'll call your setup function in our test code, so
// don't call it in your code.
// setup();