xxxxxxxxxx
40
var dir;
var gap = 0.4;
function setup() {
createCanvas(windowWidth, windowHeight);
var diam = windowWidth/2.5;
dir = createVector(random(-width,width), random(-height,height));
background(0);
stroke(255);
strokeWeight(5);
translate(width/2, height/2);
drawArrow(dir.heading(), diam);
noStroke();
fill(255);
ellipse(0, 0, diam, diam);
fill(255, 0, 0);
arc(0, 0, diam, diam, dir.heading() + gap, dir.heading() - gap, PIE);
stroke(255, 0, 0);
for(var a = dir.heading() + gap; a < dir.heading() - gap + TWO_PI; a+= gap) {
drawArrow(a, diam/1.5);
}
}
function drawArrow(heading, len) {
push();
rotate(heading);
line(0, 0, len, 0);
translate(len, 0);
rotate(-3*PI/4);
line(0, 0, 10, 0);
rotate(6*PI/4);
line(0, 0, 10, 0);
pop();
}