/** * Split a span into two by adding a knot in the middle. * @param n the span index */ public void splitSpan(int n) { int x = (xKnots[n] + xKnots[n+1])/2; addKnot(x, getColor(x/256.0f), knotTypes[n]); rebuildGradient(); }
/** * Construct a Gradient with the given colors, knot positions and interpolation types. * @param x the knot positions * @param rgb the colors * @param types interpolation types */ public Gradient(int[] x, int[] rgb, byte[] types) { setKnots(x, rgb, types); }
private void rebuild() { sortKnots(); rebuildGradient(); }
/** * Set a knot type. * @param n the knot index * @param type the type * @see #getKnotType */ public void setKnotType(int n, int type) { knotTypes[n] = (byte)((knotTypes[n] & ~COLOR_MASK) | type); rebuildGradient(); }
float hsb2[] = Color.RGBtoHSB((rgb2 >> 16) & 0xff, (rgb2 >> 8) & 0xff, rgb2 & 0xff, null); float t = (float)(j-xKnots[i])/spanLength; int type = getKnotType(i); int blend = getKnotBlend(i);
private void rebuild() { sortKnots(); rebuildGradient(); }
/** * Set a knot blend type. * @param n the knot index * @param type the knot blend type * @see #getKnotBlend */ public void setKnotBlend(int n, int type) { knotTypes[n] = (byte)((knotTypes[n] & ~BLEND_MASK) | type); rebuildGradient(); }
float[] hsb2 = Color.RGBtoHSB((rgb2 >> 16) & 0xff, (rgb2 >> 8) & 0xff, rgb2 & 0xff, null); float t = (float) (j - xKnots[i]) / spanLength; int type = getKnotType(i); int blend = getKnotBlend(i);
/** * Set a knot position. * @param n the knot index * @param x the knot position * @see #setKnotPosition */ public void setKnotPosition(int n, int x) { xKnots[n] = ImageMath.clamp(x, 0, 255); sortKnots(); rebuildGradient(); }
/** * Split a span into two by adding a knot in the middle. * * @param n the span index */ public void splitSpan(int n) { int x = (xKnots[n] + xKnots[n + 1]) / 2; addKnot(x, getColor(x / 256.0f), knotTypes[n]); rebuildGradient(); }
/** * Construct a Gradient. */ public Gradient() { rebuildGradient(); }
/** * Construct a Gradient with the given colors, knot positions and interpolation types. * * @param x the knot positions * @param rgb the colors * @param types interpolation types */ public Gradient(int[] x, int[] rgb, byte[] types) { setKnots(x, rgb, types); }
/** * Set a knot position. * * @param n the knot index * @param x the knot position * @see #setKnotPosition */ public void setKnotPosition(int n, int x) { xKnots[n] = ImageMath.clamp(x, 0, 255); sortKnots(); rebuildGradient(); }
/** * Set a knot color. * @param n the knot index * @param color the color * @see #getKnot */ public void setKnot(int n, int color) { yKnots[n] = color; rebuildGradient(); }
/** * Set the values of a set of knots. * @param x the knot positions * @param y the knot colors * @param types the knot types * @param offset the first knot to set * @param count the number of knots */ public void setKnots(int[] x, int[] y, byte[] types, int offset, int count) { numKnots = count; xKnots = new int[numKnots]; yKnots = new int[numKnots]; knotTypes = new byte[numKnots]; System.arraycopy(x, offset, xKnots, 0, numKnots); System.arraycopy(y, offset, yKnots, 0, numKnots); System.arraycopy(types, offset, knotTypes, 0, numKnots); sortKnots(); rebuildGradient(); }
/** * Set a knot type. * * @param n the knot index * @param type the type * @see #getKnotType */ public void setKnotType(int n, int type) { knotTypes[n] = (byte) ((knotTypes[n] & ~COLOR_MASK) | type); rebuildGradient(); }
/** * Set the values of a set of knots. * * @param x the knot positions * @param y the knot colors * @param types the knot types * @param offset the first knot to set * @param count the number of knots */ public void setKnots(int[] x, int[] y, byte[] types, int offset, int count) { numKnots = count; xKnots = new int[numKnots]; yKnots = new int[numKnots]; knotTypes = new byte[numKnots]; System.arraycopy(x, offset, xKnots, 0, numKnots); System.arraycopy(y, offset, yKnots, 0, numKnots); System.arraycopy(types, offset, knotTypes, 0, numKnots); sortKnots(); rebuildGradient(); }
/** * Set a knot blend type. * * @param n the knot index * @param type the knot blend type * @see #getKnotBlend */ public void setKnotBlend(int n, int type) { knotTypes[n] = (byte) ((knotTypes[n] & ~BLEND_MASK) | type); rebuildGradient(); }