Canvas Restore the canvas 恢复画布 - caleb531/jcanvas-docs GitHub Wiki
Restore the canvas 恢复画布
Restoring the transformation state 恢复转换状态
The restoreCanvas() method restores the last saved transformation state of the canvas. The method usually works in conjunction with the saveCanvas() method.
restoreCanvas()
方法可以恢复画布最后一次保存的转换状态。这个方法通常与saveCanvas()
联用。
$('canvas').restoreCanvas();
The method also accepts a number of parameters as an object, discussed below.
本方法也接收一些参数作为对象,下边讨论。
Restoring successively 依次恢复
Setting the count property to a positive integer will restore the canvas that many times. For example, if the count property has a value of 3, the method would restore the canvas three times.
将count
属性设置为正整数,会保存画布count
次。例如,如果count
属性的值为3,那么本方法会恢复画布3次。
$('canvas').restoreCanvas({
count: 3
});
Layers 层
Although it may seem slightly counterintuitive, the restoreCanvas() method can actually be drawn as a layer. This allows for restoring masks or transformations when drawing layers.
尽管这似乎有些违反直觉,但restoreCanvas()
方法实际上可以绘制为一个层。这个特点允许在绘制层时恢复遮罩及转换。
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').restoreCanvas({
layer: true,
name: 'restore1'
});