RadialGradientpublic class RadialGradient extends Shader
Fields Summary |
---|
private static final int | TYPE_COLORS_AND_POSITIONS | private static final int | TYPE_COLOR_CENTER_AND_COLOR_EDGE | private int | mTypeType of the RadialGradient: can be either TYPE_COLORS_AND_POSITIONS or
TYPE_COLOR_CENTER_AND_COLOR_EDGE. | private float | mX | private float | mY | private float | mRadius | private int[] | mColors | private float[] | mPositions | private int | mCenterColor | private int | mEdgeColor | private TileMode | mTileMode |
Constructors Summary |
---|
public RadialGradient(float centerX, float centerY, float radius, int[] colors, float[] stops, TileMode tileMode)Create a shader that draws a radial gradient given the center and radius.
if (radius <= 0) {
throw new IllegalArgumentException("radius must be > 0");
}
if (colors.length < 2) {
throw new IllegalArgumentException("needs >= 2 number of colors");
}
if (stops != null && colors.length != stops.length) {
throw new IllegalArgumentException("color and position arrays must be of equal length");
}
mType = TYPE_COLORS_AND_POSITIONS;
mX = centerX;
mY = centerY;
mRadius = radius;
mColors = colors;
mPositions = stops;
mTileMode = tileMode;
init(nativeCreate1(centerX, centerY, radius, colors, stops, tileMode.nativeInt));
| public RadialGradient(float centerX, float centerY, float radius, int centerColor, int edgeColor, TileMode tileMode)Create a shader that draws a radial gradient given the center and radius.
if (radius <= 0) {
throw new IllegalArgumentException("radius must be > 0");
}
mType = TYPE_COLOR_CENTER_AND_COLOR_EDGE;
mX = centerX;
mY = centerY;
mRadius = radius;
mCenterColor = centerColor;
mEdgeColor = edgeColor;
mTileMode = tileMode;
init(nativeCreate2(centerX, centerY, radius, centerColor, edgeColor, tileMode.nativeInt));
|
Methods Summary |
---|
protected Shader | copy()
final RadialGradient copy;
switch (mType) {
case TYPE_COLORS_AND_POSITIONS:
copy = new RadialGradient(mX, mY, mRadius, mColors.clone(),
mPositions != null ? mPositions.clone() : null, mTileMode);
break;
case TYPE_COLOR_CENTER_AND_COLOR_EDGE:
copy = new RadialGradient(mX, mY, mRadius, mCenterColor, mEdgeColor, mTileMode);
break;
default:
throw new IllegalArgumentException("RadialGradient should be created with either " +
"colors and positions or center color and edge color");
}
copyLocalMatrix(copy);
return copy;
| private static native long | nativeCreate1(float x, float y, float radius, int[] colors, float[] positions, int tileMode)
| private static native long | nativeCreate2(float x, float y, float radius, int color0, int color1, int tileMode)
|
|