Canvas Saving the canvas 保存画布 - caleb531/jcanvas-docs GitHub Wiki

Saving the canvas 保存画布

Saving the transformation state 保存转换状态

The saveCanvas() method saves the current canvas transformation state. The method usually works in conjunction with the restoreCanvas() method.
saveCanvas()方法可以保存当前画布的转换状态。这个方法通常与restoreCanvas()方法联用。

$('canvas').saveCanvas();

The method also accepts a number of parameters as an object, discussed below.
这个方法也接收一些参数作为对象,下边讨论。

Saving successively 依次保存

Setting the count property to a positive integer will save the canvas that many times. For example, if the count property has a value of 3, the method would save the canvas three times.
将count属性设置为正整数,就可以将画布保存count次。例如,如果count属性值为3,这个方法就会保存画布3次。

$('canvas').saveCanvas({
  count: 3
});

Layers 层

Although it may seem slightly counterintuitive, the saveCanvas()method can actually be drawn as a layer. This allows for restoring masks or transformations when drawing layers.
尽管这似乎有些违反直觉,但saveCanvas()方法实际上可以绘制为一个层。这个特点允许在绘制层时恢复遮罩或转换。
To do this, set the layer property to true, just as you would to make any other shape a layer. In addition, just as you can with any other type of layer, you can give this layer a name using the name property.
为了做到这点,要将layer属性设置为true,就像你将其它任意图形设置为层一样。还有,就像你对其它类型的层做的那样,你也可以用name属性给这个层命名。

$('canvas').saveCanvas({
  layer: true,
  name: 'save1'
});