Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.graphics.Color;

public class Main {
    /**
     * Returns a color based that is ratio% of color1 and (1 - ratio)% of color2 (including alpha).
     */
    private static int blendColors(int color1, int color2, double ratio) {
        double ir = 1.0 - ratio;

        int a = (int) (Color.alpha(color1) * ratio + Color.alpha(color2) * ir);
        int r = (int) (Color.red(color1) * ratio + Color.red(color2) * ir);
        int g = (int) (Color.green(color1) * ratio + Color.green(color2) * ir);
        int b = (int) (Color.blue(color1) * ratio + Color.blue(color2) * ir);

        return Color.argb(a, r, g, b);
    }
}