Android 学习 之 Canvas (一)

1.官方API文档中对save()方法的解释:

 

public class Canvas {
    /**
     * Saves the current matrix and clip onto a private stack. Subsequent
     * calls to translate,scale,rotate,skew,concat or clip Rect,clipPath
     * will all operate as usual, but when the balancing call to restore()
     * is made, those calls will be forgotten, and the settings that existed
     * before the save() will be reinstated.
     */
    /**
     * 保存当前的矩阵和剪裁到一个私有的堆栈,其实矩阵和剪裁就是当前Canvas的状态State
	接着调用位置,缩放,选择,倾斜,concat或者剪辑矩形,剪辑区域等将被正常操作,但是
	当restore()被调用,恢复时,这些操作都将被放弃,并且刚才调用save()之前被保存的状态将被重新恢复。
     */
    public native int save();
}

public class Canvas {
    /**
     * This call balances a previous call to save(), and is used to remove all
     * modifications to the matrix/clip state since the last save call. It is
     * an error to call restore() more times than save() was called.
     */
    /**
     * 移除自上次保存操作后所做的修改,恢复到之前的状态,因为是堆栈实现,所以pull操作不能不等于push操作,
	save()和restore()应该成对使用,否则恢复的状态就很有可能是错误的
     */
    public native void restore();
}

 

 

你可能感兴趣的:(android,canvas,api)