xxxxxxxxxx
58
function setup() {
createCanvas(400, 400);
drawingContext.setLineDash([3])
}
R = 100
ms = 10/500*200
cs = 39/500*200
lim = 80/500*200
function draw() {
background(220);
translate(width/2, height/2)
m = createVector(0,0);
c = createVector(0, -R);
ac = createVector(-c.x, -c.y);
bm = p5.Vector.sub(ac,m);
stroke(0,0,0,100);
for (var i = 0; i < R*(PI+HALF_PI)/cs ; i++) {
noFill();
// cat and mouse paws
circle(m.x,m.y, 5);
circle(c.x,c.y, 5);
line(0,0,bm.x,bm.y);
noFill();
// cat reach
circle(c.x,c.y,lim);
fill(0);
// cat moves
c.rotate(cs/R);
bm.rotate(cs/R);
// now where does the mouse go ?! @r4h9f8uiwjhoawjogp awereeeeeeeeeeeee
if (i > 5) {
m.add(p5.Vector.sub(ac,m))
} else {
m.add(p5.Vector.mult(p5.Vector.normalize(p5.Vector.sub(bm,m)),ms));
}
// m.add(p5.Vector.mult(p5.Vector.normalize(bm),ms));
line(m.x,m.y,c.x,c.y);
if ( m.mag() > 100) {
break;
}
}
noLoop();
}