internal void OrderColors() { if (!Ramp.Colors.Any()) { return; } int oldBaseIndex = (int)Math.Floor(Ramp.BaseColorIndex); float adjustment = Ramp.BaseColorIndex - oldBaseIndex; var entries = Palette.RampEntries(Ramp); var order = PaletteRamp.ColorLumaOrder(entries.Select(x => x.Color)).ToList(); var colors = order .Select(x => Ramp.Colors[x]) .ToList(); var adjustments = order .Select(x => Ramp.Adjustments[x]) .ToList(); Ramp.SetColors(colors, adjustments); float newBaseIndex = oldBaseIndex; if (oldBaseIndex >= 0 && oldBaseIndex < this.Count) { newBaseIndex = order.IndexOf(oldBaseIndex); } newBaseIndex += adjustment; Ramp.BaseColorIndex = newBaseIndex; }
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); }
private float SaturationMultiplier(GeneratedColorPalette rawPalette, PaletteRamp ramp, int index) { Color target = rawPalette.GetColor(ColorValues[index]); Color source = ramp.Colors[index]; XnaHSL targetHsl = new XnaHSL(target); XnaHSL sourceHsl = new XnaHSL(source); return(SaturationMultiplier(targetHsl, sourceHsl)); }
public void AddRamp() { string name = "New Ramp"; for (int index = 1; Ramps.Any(x => x.Name == name); index++) { name = string.Format("New Ramp{0}", index); } var ramp = new PaletteRamp(name, _DarkestColor); Ramps.Add(ramp); }
public void RefreshDarkestColor() { if (Palette.Any()) { var order = PaletteRamp.ColorLumaOrder(GetRemappedPalette()); order = order .Where(x => Palette[x].Color.A > 0) .ToList(); if (order.Any()) { int index = order.ElementAt(0); SetDarkestColor(index); } } }
internal List <PaletteEntry> RampEntries(PaletteRamp ramp) { var result = ramp.Colors .Select(color => { int index = ColorIndex(color); if (index >= 0) { return(GetEntry(index)); } else { return(new PaletteEntry(color, 0)); } }) .ToList(); return(result); }
public void AddRamp(List <Color> sourceColors, List <int> sourceWeights) { // Order the colors by lightness var order = PaletteRamp.ColorLumaOrder(sourceColors); var orderedColors = order .Select(x => sourceColors[x]) .ToList(); var orderedWeights = order .Select(x => sourceWeights[x]) .ToList(); AddRamp(); int rampIndex = Ramps.Count - 1; foreach (int index in order) { int colorIndex = AddColor(orderedColors[index], orderedWeights[index]); AddColorToRamp(colorIndex, rampIndex); } }
internal void ReplaceRamp(int index, PaletteRamp ramp) { Ramps[index] = ramp; }
private SpriteRamp(SpriteRamp source) { Palette = source.Palette; Ramp = (PaletteRamp)source.Ramp.Clone(); }
internal SpriteRamp(SpritePalette palette, PaletteRamp ramp) { Palette = palette; Ramp = ramp; }
private PaletteRamp(PaletteRamp source) { CopyFrom(source); }