Пример #1
0
 public override void Read(BinaryReader input)
 {
     Name             = input.ReadString();
     IsIndexedPalette = input.ReadBoolean();
     input.ReadTactileContent(Palette, PaletteEntry.GetEmptyInstance());
     input.ReadTactileContent(Ramps, PaletteRamp.GetEmptyInstance());
     _DarkestColor = _DarkestColor.read(input);
 }
Пример #2
0
        public int AddColor(Color color, int weight)
        {
            int index = ColorIndex(color);

            if (index >= 0)
            {
                return(index);
            }
            else
            {
                var entry = new PaletteEntry(color, weight);
                Palette.Add(entry);
                return(Palette.Count - 1);
            }
        }
Пример #3
0
        private void SetValue(int index, float value)
        {
            // Can't adjust the base color value
            if (index == Ramp.BaseColorIndex)
            {
                return;
            }

            PaletteEntry entry = GetEntry(index);
            var          color = entry.Color;

            // Update the gradient so that this index natrually has this value
            Ramp.Generator.AdjustValue(
                color,
                this.BaseColor,
                value);
        }
Пример #4
0
        public void RefreshAdjustments()
        {
            var basePalette = GetDefaultColorPalette();
            var entries     = Palette.RampEntries(Ramp);
            var values      = entries
                              .Select(x => x.Color)
                              .Select(x => basePalette.GetValue(x))
                              .ToArray();

            for (int i = 0; i < Ramp.Count; i++)
            {
                // Get the adjustment that turns the palette color back into
                // the ramp color
                Color        source = basePalette.GetColor(values[i]);
                PaletteEntry entry  = entries[i];
                Color        target = entry.Color;

                var adjustment = ColorVector.ColorDifference(source, target, Ramp.BlueYellowAdjustments);
                Ramp.SetAdjustment(i, adjustment);
            }
        }
Пример #5
0
        public XnaHSL GetHsl(float index)
        {
            PaletteEntry entry = Palette.GetEntry(Ramp.Colors.FirstOrDefault());
            XnaHSL       black = new XnaHSL(entry.Color);

            black = black.SetSaturation(0f);
            black = black.SetLightness(0f);
            entry = Palette.GetEntry(Ramp.Colors.LastOrDefault());
            XnaHSL white = new XnaHSL(entry.Color);

            white = white.SetSaturation(0f);
            white = white.SetLightness(1f);

            XnaHSL left  = black;
            XnaHSL right = white;

            for (int i = 0; i <= Ramp.Count; i++, index -= 1f, left = right)
            {
                if (i == Ramp.Count)
                {
                    right = white;
                }
                else
                {
                    entry = Palette.GetEntry(Ramp.GetColor(i));
                    right = new XnaHSL(entry.Color);
                }

                if (index <= 0f)
                {
                    XnaHSL hslResult = XnaHSL.Lerp(left, right, (index + 1));
                    return(hslResult);
                }
            }
            return(right);
        }
Пример #6
0
 public PaletteEntry(PaletteEntry source)
 {
     CopyFrom(source);
 }