foone / SierraDeathGenerator

Generate fake screenshots from video games
https://deathgenerator.com
GNU General Public License v3.0
625 stars 62 forks source link

Add "Copy to Clipboard" as an option alongside "Save" #50

Open luser opened 3 years ago

luser commented 3 years ago

It would be nice to be able to copy the resulting image directly to the clipboard instead of having to save or upload it, since many sites allow pasting an image directly into the input (Twitter and Discord both support this, for example). The code for this should be pretty straightforward, adding a button and then code for it near the existing code for Save, perhaps like:

$('#copy').click(function(){
  canvas.toBlob(imgBlob => {
    navigator.clipboard.write([
          new ClipboardItem({
              'image/png': imgBlob
          })
      ]);
  });
)

It might also be useful to have something indicate that the copy was successful, like a "Copied to clipboard" notification that disappeared after a short while.

If you're interested I could provide this in the form of a pull request.