コード例 #1
0
 public Color getColor(float value)
 {
     if (value > maxValue || value < minValue)
     {
         throw new System.Exception("invalid parameters: [" + min + "," + max + "] " + value);
     }
     return(HSVColor.lerpHue(min, max, (value - minValue) / (maxValue - minValue)).toRGB());
 }
コード例 #2
0
    public Color temperatureColor(float temperature)
    {
        HSVColor magenta = new HSVColor(0.90f, 1, 1);
        HSVColor red     = new HSVColor(0, 1, 1);
        float    t       = MyMath.remap(temperature, min, max, 0, 1.166f);

        if (t >= 0.166f)
        {
            return(HSVColor.lerpHue(magenta, red, t - 0.166f).toRGB());
        }
        else
        {
            return(Color.Lerp(Color.white, magenta.toRGB(), t / 0.166f));
        }
    }
コード例 #3
0
    Color directionToColor(Direction d)
    {
        HSVColor mag = new HSVColor(Color.magenta);
        HSVColor red = new HSVColor(Color.red);

        if (d.Equals(Direction.North()))
        {
            return(HSVColor.lerpHue(mag, red, 0).toRGB());
        }
        if (d.Equals(Direction.NorthEast()))
        {
            return(HSVColor.lerpHue(mag, red, 0.125f).toRGB());
        }
        if (d.Equals(Direction.East()))
        {
            return(HSVColor.lerpHue(mag, red, 0.25f).toRGB());
        }
        if (d.Equals(Direction.SouthEast()))
        {
            return(HSVColor.lerpHue(mag, red, 0.5f).toRGB());
        }
        if (d.Equals(Direction.South()))
        {
            return(HSVColor.lerpHue(mag, red, 0.625f).toRGB());
        }
        if (d.Equals(Direction.SouthWest()))
        {
            return(HSVColor.lerpHue(mag, red, 0.75f).toRGB());
        }
        if (d.Equals(Direction.West()))
        {
            return(HSVColor.lerpHue(mag, red, 0.875f).toRGB());
        }
        if (d.Equals(Direction.NorthWest()))
        {
            return(HSVColor.lerpHue(mag, red, 1).toRGB());
        }
        return(Color.white);
    }