From Graphics to HTML in div

Hi all,

I’m in WEBGL mode which doesn’t support image() (in 0.5.16 anyway) - how can I load a graphics into a an html div?

JS Fiddle here

Thanks,
Charles

1 Like

I guess you could do:

document.getElementById("my-image").innerHTML = '<img src="myimage.jpg">'

or just add that into the html itself.

Did you read the question or did I misunderstand your answer? - The image isn’t saved locally

If I am not mistaken you can use a link in src, so that is not a problem

document.getElementById("my-image").innerHTML = '<img src="http://i.imgur.com/jiItp64.png">'

<h1>
3D with WebGL
</h1>
<div id="my-image">
  
  <img src="http://i.imgur.com/jiItp64.png">
</div>
1 Like

I’m creating my Graphics on the “fly” therefore I don’t have src link

There are many examples here that you can use then.

Needs to be done with P5…

I can’t help you then. Sorry.

You may try out show() and/or parent() methods: :man_shrugging:

  1. show() -> p5js.org/reference/#/p5.Element/show
  2. parent() -> p5js.org/reference/#/p5.Element/parent
1 Like

Thanks @GoToLoop that did the trick

JSFiddle

1 Like