xxxxxxxxxx
28
var moon, //image
moonCopy, //resized image of the image (visible)
imageRatio; //ratio of the image h/w
function preload() {
moon=loadImage("L_O.jpg", img => moonCopy = img.get());
}
function setup() {
createCanvas(windowWidth, windowHeight);
imageRatio = moon.height/moon.width;
print("imageRatio: "+imageRatio);
moonCopy.resize(windowWidth,0);
}
function draw() {
background(255);
image(moonCopy,0,0);
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
print("resizing to: "+windowWidth+" "+windowHeight);
if (windowWidth < moon.width){
moonCopy = moon.get();
moonCopy.resize(windowWidth,0);
}
}