Hi,
I’m attempting to use p5js to place a bunch of images in a grid like fashion on a canvas and have the user save the sketch to use as a background for their phone.
I get the users phone resolution using displayWidth, displayHeight and set it as my canvas.
I load the image into an img variable using loadImage() and then call the image function to draw my image onto the canvas.
However when I call the image function to draw the image and resize it for example
image(img, 0, 0, 300, 300) and download it to my phone, the canvas resolution says what’s expected - displayWidth, displayHeight, but the interesting thing is that the image enhanced at least 3x than what I specified in the image function.
I assume this has to do with pixelDensity so I tried calling the function before I call the image() but it didn’t work.
Can anyone explain to me why this happens?
Here is my code:
var img;
function preload() {
str = 'https://i2.cdn.turner.com/money/dam/assets/161109153420-my-first-job-sean-combs-640x640.jpg';
img = loadImage(str);
}
function setup() {
cnv = createCanvas(displayWidth, displayHeight);
background(100);
}
function draw() {
// pixelDensity(1);
image(img, 0, 0, 200, 200);
saveCanvas('background', 'jpg')
}
Thank you!