1.线性渲染器 LinearGradient
构造方法1: LinearGradient(int x1,int y1,int x2,int y2,int startColor,int endColor,TileMode tileMode)
参数说明:x1,y1为起始点坐标,x2,y2为结束点坐标,startColor为起始点颜色,endColor为终点颜色,tileMode为端点之外的着色规则


构造方法2:LinearGradient(float x1, float y1, float x2, float y2, int colors[] ,float positions[], TileMode tile)
参数说明:x1,y1为起始点坐标,x2,y2为结束点坐标 ,colors为颜色集合,positions着色比例(可为空,如果不为空时,长度和colors长度保持一致,否则抛出异常)


positions说明:
positions里面的值对应colors相对应的颜色从百分比多少开始渲染,如上图,0表示红色从0开始,到0.2即是百分20的时候渲染蓝色。
TileMode说明:
CLAMP 最后一个像素拉伸
REPEAT 重复填充
MIRROR 镜像
2.环形渲染器RadialGradient


3.扫描渲染 SweepGradient


4.位图渲染BitmapShader


因为x轴和y轴都设置了最后一个像素拉伸,如果将x轴设置为重复填充则为下图显示效果


5组合渲染ComposeShader
组合渲染为上面四种任意两种组合,且只能是两种


网友评论