List of utility methods to do Color Interpolate
java.awt.Color | interpolate(java.awt.Color a, java.awt.Color b, float portion) interpolate synchronized (s_rvBuffer) { a.getComponents(s_aBuffer); b.getComponents(s_bBuffer); for (int i = 0; i < 4; i++) { s_rvBuffer[i] = (s_aBuffer[i] * (1 - portion)) + (s_bBuffer[i] * portion); return new java.awt.Color(s_rvBuffer[0], s_rvBuffer[1], s_rvBuffer[2], s_rvBuffer[3]); |
Color | interpolate2Color(final Color first, final Color second, float fraction) interpolate Color final float INT_TO_FLOAT = 1f / 255f; fraction = Math.min(fraction, 1f); fraction = Math.max(fraction, 0f); final float R1 = first.getRed() * INT_TO_FLOAT; final float G1 = first.getGreen() * INT_TO_FLOAT; final float B1 = first.getBlue() * INT_TO_FLOAT; final float A1 = first.getAlpha() * INT_TO_FLOAT; final float R2 = second.getRed() * INT_TO_FLOAT; ... |
Color | interpolateColor(Color color0, Color color1, double mixer, boolean useHue) interpolate Color if (color0 == null && color1 == null) return Color.black; if (color1 == null) return color0; if (color0 == null) return color1; if (mixer <= 0d) return color0; ... |
Color | interpolateColor(final Color minColor, final Color maxColor, final int currentClass, final int numOfClasses) returns the interpolated color of a color map defined by start and end color. final float[] minhsb = Color.RGBtoHSB(minColor.getRed(), minColor.getGreen(), minColor.getBlue(), null); final float[] maxhsb = Color.RGBtoHSB(maxColor.getRed(), maxColor.getGreen(), maxColor.getBlue(), null); final float minHue = minhsb[0]; final float maxHue = maxhsb[0]; final float minSat = minhsb[1]; final float maxSat = maxhsb[1]; final float minBri = minhsb[2]; final float maxBri = maxhsb[2]; ... |
Color | interpolateRGB(Color start, Color end, float p) interpolate RGB if (p <= 0.5) { final float a = 2 * (0.5f - p); final float b = (int) (2f * p * 255f); return new Color((int) (a * start.getRed() + b), (int) (a * start.getGreen() + b), (int) (a * start.getBlue() + b), (start.getAlpha() + end.getAlpha()) / 2); } else { final float a = 2 * (p - 0.5f); final float b = (int) (2f * (1f - p) * 255f); ... |