I see you can use createA()
in P5 to add hyperlinks on texts, is there anyway to use an image as a hyperlink in P5?
please format code with </> button * homework policy * asking questions
I see you can use createA()
in P5 to add hyperlinks on texts, is there anyway to use an image as a hyperlink in P5?
please format code with </> button * homework policy * asking questions
Although the images don’t show up due to the site they link to doesn’t exist anymore you can still study the sketch from the link below on how to place a createImg() as a child element of a createA() using the method parent():
Here is what I come up with
let img;
function setup() {
createCanvas(400, 400);
link = createA('http://www.p5js.org/', '','top');
}
function draw() {
img=createImg('asterisk.png','www.p5js.org').parent(link);
img.position(0, 0);
img.size(img.width,img.height);
}
The image does have a link now, thanks for pointing the direction.
Just wanna make sure this is the correct way to use the method parent()
and also, for some reason the third parameter of CreateA function doesn’t seem to work correctly.
link = createA('http://www.p5js.org/', '','top');
link = createA('http://www.p5js.org/', '','_top');
Oh by the way you shouldn’t createImg
in the draw loop - which will generate the DOM every frame instead of making it once.