private static Color GetBestPixel(Color true_color, IColorAlgorithm algorithm, IJavaVersion mapping) { // partial transparency is not allowed if (true_color.A < 128) { return(Color.FromArgb(0, 0, 0, 0)); } if (NearestColorCache.TryGetValue(true_color, out var cached)) { return(cached); } Color best_approximate = Color.Empty; double mindist = Double.PositiveInfinity; // find the color in the palette that is closest to this one foreach (Color mapcolor in mapping.GetAllColors().Where(o => o.A == 255)) { double distance = algorithm.Distance(true_color, mapcolor); if (mindist > distance) { mindist = distance; best_approximate = mapcolor; } } NearestColorCache.Set(true_color, best_approximate); return(best_approximate); }
public MapCreationSettings(Image original, int splitW, int splitH, InterpolationMode interpMode, bool dither, bool stretch, IColorAlgorithm algorithm) { Original = original; SplitW = splitW; SplitH = splitH; InterpMode = interpMode; Dither = dither; Stretch = stretch; Algorithm = algorithm; }
public ContainersCreator(IFilteredWords filteredWords, ICloudLayouter circularLayouter, IColorAlgorithm colorAlgorithm, string fontName = "Arial", int maxFontSize = 50) { this.circularLayouter = circularLayouter; this.colorAlgorithm = colorAlgorithm; containersInfo = new List <ContainerInfo>(); this.filteredWords = filteredWords.FilteredWordsList; this.maxFontSize = maxFontSize; this.fontName = fontName; InitializeContainers(); }
public ColorAlgorithmDisplay(string name, IColorAlgorithm algorithm) { Name = name; Algorithm = algorithm; }