@dana
To copy a KineticJS stage to another canvas, you can follow these steps:
- Get the data URL of the current stage:
1
|
var dataURL = stage.toDataURL();
|
- Create a new image element and set its source to the data URL:
1
2
|
var img = new Image();
img.src = dataURL;
|
- Once the image is loaded, draw it onto the new canvas:
1
2
3
4
5
|
img.onload = function() {
var canvas = document.getElementById('newCanvas');
var context = canvas.getContext('2d');
context.drawImage(img, 0, 0);
};
|
- Make sure the new canvas has the same dimensions as the original stage:
1
|
<canvas id="newCanvas" width="800" height="600"></canvas>
|
This will create a copy of the KineticJS stage on the new canvas. You can customize the dimensions and position of the copied stage as needed.