Image link conversion

You must cope with asynchronicity of image loading.
There is a project to handle image from clippboard to costume: Snap! Build Your Own Blocks
"clip 2 costume" implements loading image with Promise and using outcome in Snap!
Waiting on promise is based on someone previous work i'm not able to credit for, right now.

Of course it can be implemented as asynchronous and data transfered to Snap! with broadcast or global variable.

var img = new Image();
img.onload = function () {
  canvas = newCanvas(new Point(img.width, img.height), true);
  canvas.getContext('2d').drawImage(img, 0, 0);
*** send 'new Costume( canvas, "Clipboard")' with broadcast or shared variable...
};
img.src = url;
1 Like