22 lines
467 B
JavaScript
22 lines
467 B
JavaScript
let img;
|
|
let imgWidth = 100;
|
|
|
|
function setup() {
|
|
createCanvas(800, 600);
|
|
imageMode(CENTER);
|
|
|
|
img = loadImage('assets/light.jpg');
|
|
|
|
// Promisify this function
|
|
// img = loadImage('assets/light.jpg', (loadedImage) => {
|
|
// const ratio = loadedImage.height / loadedImage.width;
|
|
// loadedImage.height = imgWidth * ratio;
|
|
// loadedImage.width = imgWidth;
|
|
// });
|
|
}
|
|
|
|
function draw() {
|
|
background(255);
|
|
if (img) image(img, width / 2, height / 2);
|
|
}
|