// Rouann Chen
// rouanc
// Section B
var angle;
var pos;
var side;
function setup() {
side = 60;
createCanvas(400, 400);
angle = 0;
pos = p5.Vector.fromAngle(0);
setRadius();
}
function setRadius() {
var m = min(width, height);
var radius = m/2-side*0.6;
pos.setMag(radius);
}
function drawRect(pos) {
push();
translate(pos.x, pos.y);
rotate(angle);
rect(-side/2, -side/2, side, side);
pop();
}
function draw() {
translate(width/2, height/2);
drawRect(p5.Vector.mult(pos.rotate(TWO_PI/5), sin(angle)));
drawRect(p5.Vector.mult(pos.rotate(TWO_PI/5), sin(angle)));
drawRect(p5.Vector.mult(pos.rotate(TWO_PI/5), sin(angle)));
drawRect(p5.Vector.mult(pos.rotate(TWO_PI/5), sin(angle)));
drawRect(p5.Vector.mult(pos.rotate(TWO_PI/5), sin(angle)));
angle += 0.029;
pos.rotate(sin(angle)/40);
}
I was inspired by snakes and wanted to draw something that moves infinitely. Instead of using lines, I tried to use endless rectangles connected together to represent a single line.