Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
I believe that after reading the three articles mentioned in the previous article, we have a deeper understanding of color processing.
Before we talk about the effect of color gradients, how do you do that, you need to apply color rendering. Let's start with a few important classes about color rendering in the Android API:
Shader,bitmapshader,composeshader,lineargradient,radialgradient,sweepgradient
Look at the relationship between them:
public class Shader extends Object
The class is primarily a horizontal span that returns the color of the drawing when it is the base class. Its subclasses can function with Piant. by Paint.setshader (Shader Shader); To achieve some rendering effects. The function and graphics do not function and bitmap.
The constructor method is the default construction method.
Enumeration:
Emun Shader.tilemode
3 modes of tiling are defined:
static final Shader.tilemode CLAMP: Edge stretch.
static final Shader.tilemode MIRROR: Alternating between horizontal and vertical, there is no gap between the two adjacent images.
Static Final Shader.tillmode Repeta: Repeated in both horizontal and vertical directions, with gap gaps between two adjacent images.
Method:
1. boolean Getloaclmatrix (Matrix Localm); If shader has a non-native matrix, it returns TRUE.
Localm: If not null, the local matrix is set to shader.
2. void Setlocalmatrix (Matrix localm);
Sets the local matrix of the shader, if Localm is empty, resets the local matrix of the shader.
Direct subclasses of Shader:
bitmapshader : Bitmap Image rendering
lineargradient : Linear rendering
radialgradient : Ring Rendering
sweepgradient : Scanning gradient rendering/gradient rendering
Composeshader : Combined rendering, which can be combined with several other sub-classes
Is it much like the relationship between animation and its subclasses (Alphaanimation,rotateanimation,scaleanimation,translateanimation, Animationset)
Both specific rendering effects and a combination of rendering effects
Below are the steps to use shader:
1. Building Shader objects
2. Set the Render object through the Setshader method of paint
3. Set the Render object
4. Use this Paint object when drawing
Android Color Rendering (iii) shader color rendering