[SOLVED] Is it possible to draw data back into a DrawingCanvas?

0 favourites
  • 8 posts
From the Asset Store
Helping streamers give their viewers more excitement.
  • Is it possible to save a DrawingCanvas and insert it back into the DrawingCanvas? I know it's possible to load the data into a sprite through either Save DrawingCanvas or Snapshot of screen.

  • You can use "Save image" action, and when it's finished, DrawingCanvas.SavedImageURL expression. Save it to Local Storage the same way you did with canvas snapshot. (via AJAX and BinaryData).

    To load the back into the canvas, I believe you need to load into a temporary sprite and paste this sprite on the canvas.

  • The snapshots feature lets you read the canvas pixel data, modify pixels with events, and then put that pixel data back in to the canvas.

  • Tried to paste sprite into DrawingCanvas, but it doesn't redraw the pixels for some reason:

    https://www.dropbox.com/s/befjnf45t7le780/pasteDrawingCanvasTest.c3p?dl=0

    Also screenshot here if you don't open the c3p:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • In System > On Canvas snapshot, the snapshot is already available, no need to load it via AJAX. And pasting an object is position sensitive, so the object needs to overlap the canvas in order to be pasted there. You can just set the position/size to the canvas > paste it > set the position back to where it was initially during the tick, this will not cause the sprite to flicker btw.

    I think doing it like this will also resize the image, depending on what you do that´s exactly what you may want.

    Load the image forum... Come on

  • Load the image forum? What do you mean. My screenshots don't seem to post BTW. Trying again below.

    Thanks Wacky. This works. Strange that I can't destroy the Render object after pasting. I have to change opacity to 0. If I destroy, nothing appears on the DrawingCanvas, even if I do "Wait for previous actions" after pasting.

    Screenshot:

  • My screenshots don't seem to post BTW. Trying again below.

    That´s what I mean with Load the image forum. Screenshots sometimes just don´t load :U

    Strange that I can't destroy the Render object after pasting. I have to change opacity to 0. If I destroy, nothing appears on the DrawingCanvas, even if I do "Wait for previous actions" after pasting.

    Don´t really know why this could be. Pasting isn´t marked as asynchronous, that´s why wait for previous actions doesn´t have an effect.

  • Thanks for the explanation and help!

    Also, the reason why I used AJAX is to copy the BinaryData into LocalStorage. If there isn't a better way to copy the data to localStorage to load into a Sprite later, I guess I'll keep the AJAX in my file.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)