Пример #1
0
        private List <Tuple <float, float> > Errors(
            PaletteParameters parameters,
            List <PaletteEntry> ramp,
            Range <float> range,
            int count,
            Func <PaletteGenerator, float, float> function)
        {
            PaletteGenerator  copyGenerator  = (PaletteGenerator)Clone();
            PaletteParameters copyParameters = (PaletteParameters)parameters.Clone();
            float             interval       = (range.Maximum - range.Minimum) / count;

            var errors = new List <Tuple <float, float> >();

            for (int i = 0; i <= count; i++)
            {
                float value = range.Minimum + interval * i;
                function(copyGenerator, value);

                // Kind of necessary for user facing values
                // Minimize error on blue shadow
                copyParameters.MinimizeBlueError(copyGenerator, ramp);
                // Minimize error on yellow light
                copyParameters.MinimizeYellowError(copyGenerator, ramp);

                var   palette = copyGenerator.GetPalette(copyParameters);
                float error   = palette.GetError(ramp);
                errors.Add(Tuple.Create(value, error));
            }

            return(errors);
        }
Пример #2
0
        private List <Tuple <float, float> > Errors(
            PaletteGenerator generator,
            List <PaletteEntry> ramp,
            Range <float> range,
            int count,
            Func <PaletteParameters, float, float> function)
        {
            PaletteParameters copyParameters = (PaletteParameters)Clone();
            float             interval       = (range.Maximum - range.Minimum) / count;

            var errors = new List <Tuple <float, float> >();

            for (int i = 0; i <= count; i++)
            {
                float value = range.Minimum + interval * i;
                function(copyParameters, value);

                var   palette = generator.GetPalette(copyParameters);
                float error   = palette.GetError(ramp);
                errors.Add(Tuple.Create(value, error));
            }

            return(errors);
        }