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); }
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); } }
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); }
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); } }
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); }
public PaletteEntry(PaletteEntry source) { CopyFrom(source); }