简体   繁体   中英

Get canvas as an image from link

I have a p5.js canvas on my webpage, I want to get that canvas as an image from the link, just like a raw media file being hosted on a website, such that I can use it as just a normal get media link, not sure what the technical term is.

Is this possible, or will I have to download the image locally first and just use it from the drive?

I don't know of a way to do this, but you have some options.

Option 1: embed your sketch as a canvas element, which is what p5.js is designed to do. My gut tells me that this is probably what you should really do.

Option 2: save your sketch (or several versions of your sketch) as an image by right-clicking it, and then serve that as a normal image.

Option 3: do some kind of server-side rendering of a p5.js canvas, and serve that as an image. This is pretty advanced, but you can google "p5.js server side" for more info. My gut tells me that this is probably not what you should really do.

Honestly it sounds like you're trying to use p5.js for something it wasn't meant for. Most places you can embed an image, you can embed a p5.js canvas, so my guess is that you probably want to do that instead. But server-side rendering is the direction I would explore if you're super curious.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM