/*
 * Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.wyrez.shootingstars.helper;

import com.jme3.math.ColorRGBA;

/**
 *
 * @author Darth Affe
 */
public class ColorHelper {

    public static ColorRGBA calcColor(float value) {
        int r, g, b;
        if (value < 0.25f) {
            r = 0;
            g = Math.round(255 * value / 0.25f);
            b = 255;
        } else if (value < 0.5f) {
            r = 0;
            g = 255;
            b = Math.round(255 * ((0.25f - (value - 0.25f)) / 0.25f));
        } else if (value < 0.75f) {
            g = 255;
            r = Math.round(255 * (value - 0.5f) / 0.25f);
            b = 0;
        } else {
            g = Math.round(255 * ((0.25f - (value - 0.75f)) / 0.25f));
            r = 255;
            b = 0;
        }
        return new ColorRGBA((float) r / 255f, (float) g / 255f, (float) b / 255f, 1f);
    }
}
