문제

Here is how i decorate the stage:

every time user drag an image outside KineticJS:
    create a image onto where it is dropped
    layer.add(new_image)
    stage.add(layer)
finally:document.getElementById('save').addEventListener('click', function() {
    stage.toDataURL({
        callback: function(dataUrl) {
        window.open(dataUrl);
        }
    });
}, false);

And there is a button with id=save in html

All the image are from my local machine. Any suggestions? THX!!

도움이 되었습니까?

해결책

You shouldn't add the layer to the stage every time an image is added. What you should do is:

 layer.add(new_image);
 layer.draw(); //draws the new image added to the layer

Also, your toDataURL method looks correct, in fact it looks exactly like this tutorial if you haven't checked it out yet.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top