xxxxxxxxxx
71
let longv;
const bgc = 0;
const lc = 255;
function setup() {
createCanvas(1440,810,SVG);
longv = createVector(max(height,width)*2,0);
}
function executeTwice(){
background(bgc);
// drawRhumbNet(createVector(height/2,height/2),
// createVector(max(width,height)/2.2, 0));
// drawRhumbNet(createVector(width * random(),height * random()),
// createVector(max(width,height)/2 * (0.2 + random() * 0.8), 0));
drawRhumbNet(createVector(width * random(),height * random()),
createVector(max(width,height)/2 * (0.2 + random() * 0.8), 0));
}
function drawRhumbNet(center, radius){
strokeWeight(0.25);
stroke(lc);
for(let i=0;i<15;i++){
// get the center of the windrose
let windrose = p5.Vector.add(center, p5.Vector.rotate(radius, i*PI*0.125));
for(let j=0;j<16-i;j++){
// // draw hella lines thru the windrose
let v = p5.Vector.rotate(longv, (2*i+j+8)*PI*0.0625);
line(windrose.x-v.x,windrose.y-v.y,windrose.x+v.x,windrose.y+v.y);
}
}
stroke(bgc);
strokeWeight(5);
fill(lc)
for(let i=0;i<16;i++){
// get the center of the windrose
let windrose = p5.Vector.add(center, p5.Vector.rotate(radius, i*PI*0.125));
circle(windrose.x,windrose.y,10)
}
}
function draw() {
executeTwice();
noLoop();
}
function keyPressed() {
if (key === "s") {
save("rhumb.svg")
} else if (key === "r") {
executeTwice();
}
}