xxxxxxxxxx
let field_dim = 100
var field_array = []
function setup() {
let width = 600
let height = 600
createCanvas(width, height);
background(255);
noLoop()
for (let x = 0; x < field_dim; x++) {
field_array[x] = []; // create nested array
for (let y = 0; y < field_dim; y++) {
field_array[x][y] = ((x / float(field_dim)) * 0.25*PI)+((x / float(field_dim)) * random(-1,1)*PI)
}
}
}
function draw() {
let x_step = float(width)/float(field_dim)
let y_step = float(height)/float(field_dim)
let step_length = x_step
for (let j = 0; j < 200; j++) {
var y=-200+j*15;
var x=0
var weight = 4
noFill();
strokeWeight(weight)
beginShape();
curveVertex(x,y)
for (let i = 0; i < 200; i++) {
weight-=1
curveVertex(x,y)
column_index = int(x / (width/field_dim))
row_index = int(y / (height/field_dim))
if (column_index >= field_dim || row_index >= field_dim)
{
break
}
angle = field_array[column_index][row_index]
x_step = step_length * cos(angle)
y_step = step_length * sin(angle)
x = x + x_step
y = y + y_step
}
endShape();
}
}