Fields of Grain
Random lines rotated by a sine field
Log in to post a comment.
Canvas.setpenopacity(1);
// Global code will be evaluated once.
const turtle = new Turtle();
const rot = 3.2; // min = 0.01 max = 6.28 step = 0.01
const density = 7; // min = 0 max = 20 step = 0.1
const min_length = 1.5; // min = 0 max = 10 step = 0.01
const length_range = 5; // min = 0 max = 10 step = 0.01
const x_rot = 0.01; // min = 0 max = 0.05 step = 0.0001
const y_rot = 0.03; // min = 0 max = 0.05 step = 0.0001
const num_lines = 10000; // min = 100 max = 10000 step = 100
function rot_line(x,y,length,rot) {
turtle.penup();
turtle.goto(x + Math.cos(rot * Math.PI / 180)*length/2, y + Math.sin(rot * Math.PI / 180)*length/2);
turtle.pendown();
turtle.goto(x - Math.cos(rot * Math.PI / 180)*length/2, y - Math.sin(rot * Math.PI / 180)*length/2);
}
for(let i = 0; i < num_lines; i++) {
let xi = Math.random() * 200 - 100;
let yi = Math.random() * 200 - 100;
let li = Math.random() * length_range + min_length;
rot_line(xi, yi, li, density*Math.cos(rot+xi*x_rot)*xi+density*Math.sin(rot+yi*y_rot)*yi);
}