コード例 #1
0
    //根据colorLevel获取最终颜色值
    Color colorLevel2Color(colorLevel level)
    {
        Color result = Color.black;

        switch (level)
        {
        case colorLevel.level1:
            result = new Color(0, 0, 1, 0.5f);
            break;

        case colorLevel.level2:
            result = new Color(0, 0.5f, 0.5f, 0.5f);
            break;

        case colorLevel.level3:
            result = new Color(0, 1, 0, 0.5f);
            break;

        case colorLevel.level4:
            result = new Color(1, 0.92f, 0.016f, 0.5f);
            break;

        case colorLevel.level5:
            result = new Color(1, 0, 0, 0.5f);
            break;

        case colorLevel.Others:
            result = new Color(0.5f, 0.5f, 0.5f, 0.5f);
            break;
        }
        return(result);
    }
コード例 #2
0
    //需要在GenerateColorStep执行后执行 通过权值获取颜色值
    colorLevel getColorLevelByWeight(float weight)
    {
        colorLevel result = colorLevel.end;

        for (int i = 0; i < colorStep.Count; ++i)
        {
            if (weight <= colorStep[i])
            {
                result = (colorLevel)i;
                break;
            }
        }
        return(result);
    }