예제 #1
0
        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);
        }
예제 #2
0
 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;
 }
예제 #3
0
        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();
        }
예제 #4
0
 public ColorAlgorithmDisplay(string name, IColorAlgorithm algorithm)
 {
     Name      = name;
     Algorithm = algorithm;
 }