Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.graphics.Color;

public class Main {
    public static int getBaseColor(int color) {
        if (isLight(color)) {
            return Color.BLACK;
        }
        return Color.WHITE;
    }

    private static boolean isLight(int color) {
        return Math.sqrt(Color.red(color) * Color.red(color) * .241 + Color.green(color) * Color.green(color) * .691
                + Color.blue(color) * Color.blue(color) * .068) > 130;
    }
}