Android canvas method summary most comprehensive and detailed API (summary)
common method
Canvas translate
Canvas scale
Canvas rotate
Canvas tilt skew
//SX is the corresponding angle of inclination in the x-axis direction and sy is the corresponding angle of inclination in the y-axis direction. Both values are tan values// All Tan values! All Tan values! For example, if you want to tilt 60 degrees in the x-axis direction, the small value corresponds to: Tan 60 = root 3 = 1.732! canvas.skew(0.2f,-0.8f); Canvas save and restore
Canvas provides several methods to easily change and restore the state of canvas. These methods are: save (), restore (), restoretocount (int savecount).
When translating, rotating and zooming in the canvas, we can call the save () method to save the currently modified canvas state. After calling the restore () method, the canvas will be restored to the latest save () state.
The save () method also has a return value. We can also call the restoretocount (int savecount) method and pass this return value as a parameter to restore the canvas to a specific save () state.
Note: the translation and rotation of canvas are equivalent to a layer. If you map drawbitmap first, there will be no effect in translation. Translating a blank layer must have no effect
Explanation of savelayer() and restoretocount()
In fact, these two methods are similar to save and restore, but there are some more things on the basis of the latter. For example, savelayer() has the following overloaded methods:
You can understand that the save () method saves the entire canvas, while the savelayer () can selectively save the state of a certain area. In addition, we can see that there is an int saveflags in the meal and lodging, which is set to save the object! The optional values are:
Operation results:
Draw text
Draw a circle
Draw a line
Draw an ellipse
Draw radian
rectangle
polygon
Draw Bessel curve
Draw point
Draw pictures
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.