Example #1
0
        private static void MakeStrip(IEnumerable<Tuple<HsvColor, double>> colorPoints, string filePath)
        {
            var ramp = new ColorRamp(colorPoints);

            var image = new Bitmap(500, 50);

            for (int x = 0; x < image.Width; x++)
            {
                var color = ramp.GetColor((double)x / image.Width).ToColor();

                for (int y = 0; y < image.Height; y++)
                {
                    image.SetPixel(x, y, color);
                }
            }

            image.Save(filePath);
        }
Example #2
0
        public void Render(string outputDirectory, string outputFilename, ColorRamp colorRamp)
        {
            _log.InfoFormat("Creating image ({0:N0}x{1:N0})", _resolution.Width, _resolution.Height);

            _log.Info("Loading trajectory...");

            _hitPlot.LoadTrajectories(Path.Combine(_inputInputDirectory, _inputFilename));

            _log.Info("Done loading; finding maximum...");

            var max = _hitPlot.Max();

            _log.DebugFormat("Found maximum: {0:N0}", max);

            _log.Info("Starting to render");

            var outputImg = new Bitmap(_resolution.Width, _resolution.Height);

            var processedPixels =
                _resolution
                .GetAllPoints()
                .AsParallel()
                .WithDegreeOfParallelism(GlobalArguments.DegreesOfParallelism)
                .Select(p => ComputeColor(p, max, colorRamp))
                .AsEnumerable();

            foreach (var result in processedPixels)
            {
                outputImg.SetPixel(result.Item1.X, result.Item1.Y, result.Item2);
            }

            _log.Info("Finished rendering");

            _log.Debug("Saving image");
            outputImg.Save(Path.Combine(outputDirectory, String.Format("{0}.png", outputFilename)));
            _log.Debug("Done saving image");
        }
Example #3
0
        private Tuple<Point, Color> ComputeColor(Point p, int max, ColorRamp colorRamp)
        {
            var current = _hitPlot.GetHitsForPoint(p);

            var ratio = Gamma(1.0 - Math.Pow(Math.E, -10.0 * current / max));

            return Tuple.Create(p, colorRamp.GetColor(ratio).ToColor());
        }