Log in to post a comment.

   

// 

const t = new Turtle();
const x0 = -50;
const y0 = -119 // min=-200 max=0 step=1
const stippleSize = 0.77 // min=0.1 max=5 step=0.1
const density = 0.59 // min=0 max=1 step=0.1
const noise = 4.02 // min=0.001 max=10 step=0.1
const size = 25 // min=1 max=50 step=1
const type = 1 // min=1 max=5 step=1
const scale = 0.86 /// min=0.7 max=0.9 step=0.01

const nudge = 0.21 /// min=0 max=1 step=0.01;


// const value = 1 // min=0 max=50 step=1;

// Each pixel has a density chance of getting a dot.

for (let rowY = 0; rowY < size * 8; rowY = rowY + size ){
    for (let y = 0; y < size; y++) {
        for (let x = 0; x < size; x++) {
            if (Math.random() < 0.01 * rowY  * density) {
               
            switch (type) {
                case 1:
                    centeredCircle(x0 + x, y0 + y + rowY, stippleSize );
                break;

                case 2:
                    Square(x0 + x, y0 + y + rowY, stippleSize * 2 );
                break;
            
                case 3:
                    Tirangle(x0 + x, y0 + y + rowY, stippleSize * 2 );
                break;
                
                case 4:
                    centeredCircle(x0 + x, y0 + y + rowY, stippleSize );
                    Square(x0 + x, y0 + y + rowY, stippleSize * 2 );
                break;
                
                case 5:
                    centeredCircle(x0 + x, y0 + y + rowY, stippleSize );
                    Square(x0 + x, y0 + y + rowY, stippleSize * 2 );
                    Tirangle(x0 + x, y0 + y + rowY, stippleSize * 2 );
                break;

                default:
                    centeredCircle(x0 + x, y0 + y + rowY, stippleSize );

                }
            }
        }
    }

}

function centeredCircle(x,y,radius) {
    t.jump(x + Math.random() * noise, y-radius + Math.random() * noise);
    t.circle(radius);
}

function Square(x,y,side) {
    t.jump(x -side/2 + Math.random() * noise, y -side/2 + Math.random() * noise);

    for (let n=0; n < 4; n++) {
        t.forward(side);
        t.right(90);
    
    }
}

function Tirangle(x,y,side) {
    t.jump(x + Math.random() * noise, y + Math.random() * noise);
    side = side * scale;  // scale triangle to fit inside the circle

if (x % 2 === 0) {
    t.setheading(0)
    t.jump(x -side/2 + Math.random() * noise, y + nudge*side -side/2 + Math.random() * noise);

  } else {
    t.setheading(180)
    t.jump(x +side/2 + Math.random() * noise, y - nudge*side +side/2 + Math.random() * noise);

  }

    for (let n=0; n < 3; n++) {
        t.forward(side);
        t.right(120);
    }
t.setheading(0)
}