blend Colors - Android Graphics

Android examples for Graphics:Color Blend

Description

blend Colors

Demo Code

//package com.java2s;
import android.graphics.Color;

public class Main {
    public static int blendColors(int color1, int color2, float percent) {
        float inverseRation = 1 - percent;
        float r = Color.red(color1) * percent + Color.red(color2)
                * inverseRation;//from   w  w  w . java  2  s  .  c om
        float g = Color.green(color1) * percent + Color.green(color2)
                * inverseRation;
        float b = Color.blue(color1) * percent + Color.blue(color2)
                * inverseRation;
        return Color.rgb((int) r, (int) g, (int) b);
    }
}

Related Tutorials