Burning Ship Fractal II

Burning Ship #fractal using random points and optimized to give the best resolution vs speed and zoomed into the most interesting part. Play with the max_iteration to change the contrast, and the num_walks to change the resolution. Enjoy!

Log in to post a comment.

// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);

// Global code will be evaluated once.
const turtle = new Turtle();
turtle.penup();
turtle.goto(-100,-100);

//num_walks controls resolution
var num_walks = 350000;


// The walk function will be called until it returns false.
function walk(i) {
    var x = Math.random()*200-100;
    var y= Math.random()*200-100;
    
    
    var ix = x/2500.0-1.755;
    var iy = y/2500.0-0.035;
    
    var zx = ix;
    var zy = iy;
    
    var iteration = 0;
    
    //max_iteration controls contrast
    var max_iteration = 21;
    
    while (zx*zx + zy*zy < 4  &&  iteration < max_iteration) 
    {
        var xtemp = zx*zx - zy*zy + ix;
        zy = Math.abs(2*zx*zy) + iy;
        zx = Math.abs(xtemp);
        
        iteration = iteration + 1
    }
    if (iteration == max_iteration){
        turtle.goto(x,y);
        turtle.pendown();
        turtle.forward(1);
        turtle.penup();
    }
    
    return i<num_walks;
}