/** * Blends two colors, controlled by the blending factor. * A factor of {@code 0.0} will return the first color, * a factor of {@code 1.0} will return the second. * * @param pColor color 1 * @param pOther color 2 * @param pBlendFactor {@code [0...1]} * @return a new {@code Color} */ public static Color blend(Color pColor, Color pOther, float pBlendFactor) { float inverseBlend = (1f - pBlendFactor); return new Color( clamp((pColor.getRed() * inverseBlend) + (pOther.getRed() * pBlendFactor)), clamp((pColor.getGreen() * inverseBlend) + (pOther.getGreen() * pBlendFactor)), clamp((pColor.getBlue() * inverseBlend) + (pOther.getBlue() * pBlendFactor)), clamp((pColor.getAlpha() * inverseBlend) + (pOther.getAlpha() * pBlendFactor)) ); }
/** * Blends two colors, controlled by the blendfactor. * A factor of {@code 0.0} will return the first color, * a factor of {@code 1.0} will return the second. * * @param pColor color 1 * @param pOther color 2 * @param pBlendFactor {@code [0...1]} * @return a new {@code Color} */ public static Color blend(Color pColor, Color pOther, float pBlendFactor) { float inverseBlend = (1f - pBlendFactor); return new Color( clamp((pColor.getRed() * inverseBlend) + (pOther.getRed() * pBlendFactor)), clamp((pColor.getGreen() * inverseBlend) + (pOther.getGreen() * pBlendFactor)), clamp((pColor.getBlue() * inverseBlend) + (pOther.getBlue() * pBlendFactor)), clamp((pColor.getAlpha() * inverseBlend) + (pOther.getAlpha() * pBlendFactor)) ); }
/** * Blends two colors, controlled by the blending factor. * A factor of {@code 0.0} will return the first color, * a factor of {@code 1.0} will return the second. * * @param pColor color 1 * @param pOther color 2 * @param pBlendFactor {@code [0...1]} * @return a new {@code Color} */ public static Color blend(Color pColor, Color pOther, float pBlendFactor) { float inverseBlend = (1f - pBlendFactor); return new Color( clamp((pColor.getRed() * inverseBlend) + (pOther.getRed() * pBlendFactor)), clamp((pColor.getGreen() * inverseBlend) + (pOther.getGreen() * pBlendFactor)), clamp((pColor.getBlue() * inverseBlend) + (pOther.getBlue() * pBlendFactor)), clamp((pColor.getAlpha() * inverseBlend) + (pOther.getAlpha() * pBlendFactor)) ); }