Android Shader着色器浅析

Shader着色器是计算机图形学中的概念。在Android开发中,Shader的主要用法是:

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

shader就是着色器。paint就是涂料的意思。canvas是画布的意思。

通俗地说,shader就像是钢笔,paint就像是钢笔内的墨水,canvas就像是书写的纸张。

Shader有三种模式:

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:延申边缘的像素。

REPEAT:重复shader的内容。

MIRROR:镜像重复shader的内容。

 

Shader有以下五个子类:

BitmapShader:        位图渲染
LinearGradient:       线性渲染
SweepGradient:      梯度渲染
RadialGradient:       光束渲染
ComposeShader:    组合渲染

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值