Android library shaders
Android provides the shader option in its framework in the android.graphics package. A few well-known and widely used shaders are also in the Android library. Some of them are as follows:
BitmapShader: This can be used to draw a bitmap in the texture format. It also supports tiling or mirroring of the bitmap. It is very useful for creating terrain with tiling.ComposeShader: This is used to merge two shaders. So, it is very useful for masking or merging colors for two different shaders.LinearGradient: This is used to create a gradient along with the given line segment with a defined color set.RadialGradient: This is used to create a gradient along with the given circle segment with a defined color set. A radial origin and radius are provided to create the gradient.SweepGradient: This is used to create a sweep gradient color around a point with the given radius.
Here is an example:
@Override
protected void onDraw ( Canvas c)
{
float px = 100.0f;
float py = 100...