Application Color Rendering. First, we need to introduce several important classes about color rendering in the Android Api:
Shader, BitmapShader, ComposeShader, LinearGradient, RadialGradient, and SweepGradient:
Public class Shader extends Object
This class is used as the base class to return the horizontal span of the color during painting. Its subclass can be used with Piant. Use piant. setShader (Shader shader); to achieve some rendering effects. The role of the image does not work with bitmap.
The constructor is the default constructor. Enumeration:
Emun Shader. TileMode
Three tile modes are defined:
Static final Shader. TileMode CLAMP: edge stretch.
Static final Shader. TileMode MIRROR: alternate between the horizontal and vertical directions. there is no gap between the two adjacent images.
Static final Shader. TillMode REPETA: it is repeatedly placed in the horizontal and vertical directions, and there is a gap between the two adjacent images.
Method:
1. boolean getLoaclMatrix (Matrix localM); returns true if the shader has a non-local Matrix.
LocalM: if it is not null, It is set as the local matrix of the shader.
2. void setLocalMatrix (Matrix localM); set the local Matrix of the shader. If localM is empty, the local Matrix of the shader is reset. Direct subclass of Shader: BitmapShader: bitmap image rendering LinearGradient: Linear rendering RadialGradient: Annular rendering SweepGradient: Scan gradient rendering/gradient rendering ComposeShader: ComposeShader, it can be combined with several other sub-classes to see if it is similar to the relationship between Animation and its sub-classes (AlphaAnimation, RotateAnimation, ScaleAnimation, TranslateAnimation, and AnimationSet) with specific rendering effects, there are also a combination of rendering effects. The following describes how to use the Shader: 1. build a Shader object 2. set the rendering object through the setShader method of Paint 3. set the rendering object 4. this Paint object is used for painting.