abstract in lines 0

45|90

Created by mientjan on 2019/3/8
94
3

Log in to post a comment.

// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);
const PROJECTION = 100;
const AMOUNT = 1000;
const STAR_SIZE = 3;
const STAR_DEGREES = 100;
const RADIUS = 50;
const FOV = 50;

function drawStar( x, y, z){
    const s = z / RADIUS;
    const f = 1 * STAR_SIZE * s;
    const r = 1.44 * STAR_DEGREES;
    const turtle = new Turtle();
    turtle.setheading(Math.atan2(y, x) * 180 / Math.PI);
    turtle.setheading(0);
    // turtle.forward(f);
    [45, 90].forEach(deg => {
        turtle.penup();
        turtle.goto(x, y);
        turtle.pendown();
        turtle.right(deg);
        
        let end = 100;
        let start = 0;
        while(start < end){
            start += 10;
            
            turtle.forward(start);
        }
    })
    
    
}

drawStar(0, 0, 0);

function walk(i){
    const theta = Math.random() * 2 * Math.PI; // Random value between [0, 2PI]
    const phi = Math.acos((Math.random() * 2) - 1); // Random value between [-1, 1]
    
    // Calculate the [x, y, z] coordinates of the dot along the globe
    const x = RADIUS * Math.sin(phi) * Math.cos(theta);
    const y = RADIUS * Math.sin(phi) * Math.sin(theta);
    const z = (RADIUS * Math.cos(phi)) + 0;
    drawStar(x, y, z);
    
    return i < AMOUNT
}