Tornado Field

I just coded lines to be placed in a cool pattern and added sliders that changed it in interesting ways.

I feel like this post lacks technical rigor because the only two people who still post just made turtles analyzing the seeded random functions that they like to use, but the website has "toy" in the name so I probably just overthinking it.

Log in to post a comment.

Canvas.setpenopacity(1);

// Global code will be evaluated once.
const j_step = 3.5 // min = 0.5, max = 5, step = .1
const x_delta_shift = 7.9 // min = 0.1 max = 10 step = .1;
const y_delta_shift = 5.9 // min = 0.1 max = 10 step = .1;
const sin_mag = 2.7 // min = 0 max = 10 step = 0.1;
const sin_frequency = 0.2 // min = 0.1 max = 5 step = 0.1;
const max_line_length = 3 // min = 1 max = 10 step = 1;
const boarder = 10 // min = -10 max = 10 step = 1;
const angle_range = 19 // min = 0 max = 180 step = 1;
const turtle = new Turtle();
x_circle = 0;
y_circle = 0;

// The walk function will be called until it returns false.
function walk(i) {
    i = i - 100 + boarder;
    for(let j = -100 + boarder; j < 100 - boarder; j += j_step) {
        length = j/x_delta_shift - i/y_delta_shift;
        if(length > 0) {
            while(length > max_line_length) {
                length -= max_line_length;
            }
        }
        else {
            while(length < -max_line_length) {
                length += max_line_length;
            }
        }
        angle_line = Math.random()*angle_range;
        current_x = j;
        current_y = i + sin_mag*Math.sin(j * sin_frequency);
        
        turtle.penup();
        turtle.goto(current_x + Math.cos(angle_line * Math.PI / 180)*length/2, current_y + Math.sin(angle_line * Math.PI / 180)*length/2);
        turtle.pendown();
        turtle.goto(current_x - Math.cos(angle_line * Math.PI / 180)*length/2, current_y - Math.sin(angle_line * Math.PI / 180)*length/2);
    }
    
    return i < 100 - boarder;
}