Android TileMode effect water ripple effect ring gradient, androidtilemode
TileMode is an enumeration class located in the android. graphics. Shader class.
Android source code
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; }
Today, we mainly test the effects of these attributes. First, paste some test code:
private void drawTextRadial(Canvas canvas, RectF rectF) { canvas.save(); float centerX = rectF.centerX(); float centerY = rectF.centerY(); float radius = rectF.height(); RadialGradient gradient = new RadialGradient(centerX, centerY, radius, Color.GREEN, Color.RED, TileMode.CLAMP); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setStyle(Paint.Style.FILL); paint.setTextSize(TEXTSIZE); paint.setFakeBoldText(true); paint.setShader(gradient); canvas.drawText(mText, rectF.left, rectF.bottom, paint); canvas.restore(); }
CLAMP indicates that if the specified area is exceeded, the edge effect is repeated:
REPEAT means to REPEAT in the vertical and horizontal directions, to see the effect:
MIRROR indicates that the image is displayed in the vertical and horizontal directions: