Elements. Build native projects for any modern development platform, using the language(s) of your choice. Oxygene (Object Pascal), C#, Swift, Java, Go. | RemObjects Software

Mandelbrot (Windows)

Language: Silver, Platform: Island, Category: Command Line
https://github.com/remobjects/ElementsSamples/tree/master/Silver/Island/Command Line/Mandelbrot (Windows)

  • Mandelbrot
    • References
      • gc
      • Island
      • rtl
      • Swift
    • Source Files
    • Other Files

Program.swift

let cols = 78
let lines = 30

var chars = [" ",".",",","`","'",":","=","|","+","i","h","I","H","E","O","Q","S","B","#","$"]

let maxIter = count(chars)

var minRe = -2.0
var maxRe = 1.0
var minIm = -1.0
var maxIm = 1.0
var im = minIm

while im <= maxIm
{
    var re = minRe
    while re <= maxRe
    {
        var zr = re
        var zi = im
        var n = -1
        while n < maxIter-1
        {
            n += 1
            var a = zr * zr
            var b = zi * zi
            if a + b > 4.0 { break }
            zi = 2 * zr * zi + im
            zr = a - b + re
        }
        print(chars[n], separator: "", terminator: "")
        re += (maxRe - minRe) / Double(cols)
    }
    print()
    im += (maxIm - minIm) / Double(lines)
}

//Press ENTER to continue
print("Press ENTER to exit");
Console.ReadLine();