let img;
function preload() {
url='https://www.google.de/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png';
img = loadImage(url);
}
function setup() {
createCanvas(640, 480);
}
function draw() {
// put drawing code here
background(200);
image(img, 0, 0);
}
If I have a url to a specific image, how can I copy it to a variable so I can use it with p5.js?
I have successfuly set up a local server btw using sublimetext and browser sync. If I copy the image to my sketch folder I can use it with ‘loadImage(‘logo.png’)’ just fine. I am trying to skip that step so that the user can navigate to the website of their choice, grab an image and draw on it.
This demonstrates two different ways to get the image. First by referencing the url only in the function. Second, by passing the url as a variable in the function. Dont ask me tho if it passes by value or passes by reference-I dont know enough about p5.js to answer that.