14 long make(
float[] colors,
float[]
pos,
int tileMode,
long nativeLocalMatrix);
19 super(makeGradient(colors,
pos, tm, lm, gf));
24 super(makeGradient(colors,
pos, tm, lm, gf));
27 private static long makeGradient(
int[] colors,
float[]
pos,
TileMode tm,
Matrix lm,
28 GradientFactory gf)
throws IllegalArgumentException {
30 throw new IllegalArgumentException(
"Expecting equal-length colors and positions.");
33 float[] fcolors =
new float[colors.length * 4];
35 for (
int i = 0; i < colors.length; ++i) {
36 fcolors[4*i + 0] = ((colors[i] >> 16) & 0xff) / 255.0f;
37 fcolors[4*i + 1] = ((colors[i] >> 8) & 0xff) / 255.0f;
38 fcolors[4*i + 2] = ((colors[i] >> 0) & 0xff) / 255.0f;
39 fcolors[4*i + 3] = ((colors[i] >> 24) & 0xff) / 255.0f;
42 return gf.make(fcolors,
pos, tm.ordinal(), lm !=
null ? lm.getNativeInstance() : 0);
45 private static long makeGradient(
float[] colors,
float[]
pos, TileMode tm, Matrix lm,
46 GradientFactory gf)
throws IllegalArgumentException {
47 if (colors.length % 4 != 0) {
48 throw new IllegalArgumentException(
"Colors length must be a multiple of 4.");
52 throw new IllegalArgumentException(
"Colors must be 4x positions length.");
55 return gf.make(colors,
pos, tm.ordinal(), lm !=
null ? lm.getNativeInstance() : 0);