Java tutorial
//package com.java2s; /* Part of this class uses code from DurationFormatter (see license details below).*/ import android.graphics.Color; public class Main { public static int getSecurityLevelColor(final float security) { if (security > 0.5) { return Color.HSVToColor(255, new float[] { 180f * security, 100f, 100f }); } if (security > 0.1) { return Color.HSVToColor(255, new float[] { Math.max(180f * security - 30f, 0f), 100f, 100f }); } if (security > 0) { return Color.HSVToColor(255, new float[] { Math.max(180f * security - 60f, 0f), 100f, 100f }); } return Color.HSVToColor(255, new float[] { 0f, 100f, 100f }); } }