package com.nokia.tsl_data.util.excel.entity;

import java.awt.Color;

/**
 * 渐进色
 */
public interface Gradient {
    /**
     * 针对执行的数值输入d，计算对应的颜色
     */
    Color getColor(double d);

    static Color parse(String ARGBHex) {
        int a = Integer.parseInt(ARGBHex.substring(0, 2), 16);
        int r = Integer.parseInt(ARGBHex.substring(2, 4), 16);
        int g = Integer.parseInt(ARGBHex.substring(4, 6), 16);
        int b = Integer.parseInt(ARGBHex.substring(6, 8), 16);
        return new Color(r, g, b, a);
    }

    static Color parse(byte[] argb) {
        // 需要把byte（无符号整数0-255）转成int
        return new Color(argb[1] & 0xff, argb[2] & 0xff, argb[3] & 0xff, argb[0] & 0xff);
    }

    static Color parse(short[] rgb) {
        return new Color(rgb[0], rgb[1], rgb[2]);
    }
}
