Exemplo n.º 1
0
    public static Spectre.Console.Canvas Generate(int width, int height)
    {
        var canvas = new Spectre.Console.Canvas(width, height);

        var scale = 2 * MaxValueExtent / Math.Min(canvas.Width, canvas.Height);

        for (var i = 0; i < canvas.Height; i++)
        {
            var y = (canvas.Height / 2 - i) * scale;
            for (var j = 0; j < canvas.Width; j++)
            {
                var x     = (j - canvas.Width / 2) * scale;
                var value = Calculate(new ComplexNumber(x, y));
                canvas.SetPixel(j, i, GetColor(value));
            }
        }

        return(canvas);
    }