Analysis of Android Shader shader

Shader shader is a concept in computer graphics. In Android development, the main usage of Shader is:

paint.setShader(shader);
canvas.drawXxx(xx, xx, xx, xx, paint);

The shader is the shader. Paint is the meaning of paint. Canvas means canvas.

In layman's terms, the shader is like a pen, the paint is like the ink in the pen, and the canvas is like the paper for writing.

Shader has three modes:

public enum TileMode {
    /**
     * replicate the edge color if the shader draws outside of its
     * original bounds
     */
    CLAMP   (0),
    /**
     * repeat the shader's image horizontally and vertically
     */
    REPEAT  (1),
    /**
     * repeat the shader's image horizontally and vertically, alternating
     * mirror images so that adjacent images always seam
     */
    MIRROR  (2);
    
    TileMode(int nativeInt) {
        this.nativeInt = nativeInt;
    }
    final int nativeInt;
}

CLAMP: Extends the pixels on the edge.

REPEAT: Repeat the content of the shader.

MIRROR: mirrors and repeats the shader's content.

 

Shader has the following five subclasses:

BitmapShader: Bitmap rendering
LinearGradient: Linear rendering
SweepGradient: Gradient rendering
RadialGradient: Beam rendering
ComposeShader: Combined rendering

Guess you like

Origin blog.csdn.net/afunx/article/details/88412763