Android TileMode effect water ripple effect ring gradient, androidtilemode

Source: Internet
Author: User

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:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.