FileDocCategorySizeDatePackage
Gradient_Delegate.javaAPI DocAndroid 5.1 API8161Thu Mar 12 22:22:44 GMT 2015android.graphics

Gradient_Delegate

public abstract class Gradient_Delegate extends Shader_Delegate
Base class for true Gradient shader delegate.

Fields Summary
protected final int[]
mColors
protected final float[]
mPositions
Constructors Summary
protected Gradient_Delegate(int[] colors, float[] positions)
Creates the base shader and do some basic test on the parameters.

param
colors The colors to be distributed along the gradient line
param
positions May be null. The relative positions [0..1] of each corresponding color in the colors array. If this is null, the the colors are distributed evenly along the gradient line.

        if (colors.length < 2) {
            throw new IllegalArgumentException("needs >= 2 number of colors");
        }
        if (positions != null && colors.length != positions.length) {
            throw new IllegalArgumentException("color and position arrays must be of equal length");
        }

        if (positions == null) {
            float spacing = 1.f / (colors.length - 1);
            positions = new float[colors.length];
            positions[0] = 0.f;
            positions[colors.length-1] = 1.f;
            for (int i = 1; i < colors.length - 1 ; i++) {
                positions[i] = spacing * i;
            }
        }

        mColors = colors;
        mPositions = positions;
    
Methods Summary
public java.lang.StringgetSupportMessage()

        // all gradient shaders are supported, no need for a gradient support
        return null;
    
public booleanisSupported()

        // all gradient shaders are supported.
        return true;