xxxxxxxxxx
39
//https://tylerxhobbs.com/essays/2020/flow-fields
let numColumns;
let numRows;
let resolution;
let defaultAngle;
function setup() {
createCanvas(400, 400);
let left = int(width * -0.5);
let right = int(width * 1.5);
let top = int(height * -0.5);
let bottom = int(height * -1.5);
resolution = int(width * 0.05);
numColumns = (right - left) / resolution;
numRows = (top - bottom) / resolution;
defaultAngle = PI * 0.4;
background(220);
console.log(numColumns, numRows)
for(x = 0; x < numColumns; x++) {
for(y = 0; y < numRows; y++){
let angle = (y / numRows) * PI
let lineLength = resolution/2;
let a = cos(angle) * lineLength;
let o = sin(angle) * lineLength;
line(x * resolution, y * resolution, x * resolution + a, y * resolution + o);
circle(x * resolution, y * resolution, 3)
}
}
}
// function draw() {
// }