Get color from float between 0 and 1 - Android Graphics

Android examples for Graphics:Color

Description

Get color from float between 0 and 1

Demo Code


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

public class Main {
    /**//  w w  w  . j  a va 2  s  .co m
     * Get color from float between 0 and 1
     * @param fraction float between 0 and 1
     * @return color from fraction
     */
    public static int getColorFromFraction(float fraction) {
        return Color.HSVToColor(new float[] { fraction * 360, 1, 1 });
    }
}

Related Tutorials