关键字:Android,Canvas,save(),restore()3
p) v8 n* \7 d6 r+ Z
int android.graphics.Canvas.save()4 A4 K- S+ r; p* B4 x" f+ k( ^0 d
Saves the current matrix and clip onto a private stack. Subsequent calls to translate,scale,rotate,skew,concat or clipRect,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.
; [( ~4 t6 g8 k; ]! W. `. n: Z2 W- L
Returns:
The value to pass to restoreToCount() to balance this save()- J. A7 f% r0 o5 x
void android.graphics.Canvas.restore()
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.4 h& V, V) Z( j F
Canvas的save()和restore()只是对Canvas的Matrix和Clip相关的内容进行保存和恢复。/ h1 P6 U. }+ v! J
l$ u$ f% U: J5 h
在下面的示例代码中,原始的样子是这样的:. a4 [, ^: y2 q
如果注释掉了canvas.save();和canvas.restore();就会变成下面这样:9 l" g* L+ i) ]. t. v* Z
int android.graphics.Canvas.save()4 A4 K- S+ r; p* B4 x" f+ k( ^0 d
Saves the current matrix and clip onto a private stack. Subsequent calls to translate,scale,rotate,skew,concat or clipRect,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.
; [( ~4 t6 g8 k; ]! W. `. n: Z2 W- L
Returns:
The value to pass to restoreToCount() to balance this save()- J. A7 f% r0 o5 x
void android.graphics.Canvas.restore()
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.4 h& V, V) Z( j F
Canvas的save()和restore()只是对Canvas的Matrix和Clip相关的内容进行保存和恢复。/ h1 P6 U. }+ v! J
l$ u$ f% U: J5 h
在下面的示例代码中,原始的样子是这样的:. a4 [, ^: y2 q
如果注释掉了canvas.save();和canvas.restore();就会变成下面这样:9 l" g* L+ i) ]. t. v* Z