Exemple #1
0
        public void CopyTo(I2DMap <T> target, int targetStartX = 0, int targetStartY = 0)
        {
            if (target.Width < targetStartX + Width || target.Height < targetStartY + Height)
            {
                throw new ArgumentOutOfRangeException("Area to copy crosses the boundaries of a target Map2D<T>!");
            }

            for (int y = 0; y < Height; y++)
            {
                var sourcePos  = y * Width;
                var sourceSpan = new Span <T>(_rawArray, sourcePos, Width);

                target.PasteRow(sourceSpan, targetStartY + y, targetStartX);
            }
        }
Exemple #2
0
        static void SaveFrame(string path, RenderingOptions options, I2DMap <int> map)
        {
            Console.WriteLine($"Saving frame to {path}...");

            using (Image <Gray16> image = new Image <Gray16>(map.Width, map.Height))
            {
                for (int y = 0; y < map.Height; y++)
                {
                    for (int x = 0; x < map.Width; x++)
                    {
                        image[x, y] = new Gray16((ushort)Lerp(ushort.MaxValue, 0, map[x, y] / (double)options.MaxIteration));
                    }
                }

                using (var file = File.Open(path, FileMode.Create))
                    image.SaveAsPng(file);
            }

            Console.WriteLine("Successfully saved!");
        }