I'm working on simulating a drawing machine using p5.js, similar to this.
I have already created the positioning of the arm relative to the motor positions. The idea I'm trying to recreate is holding a pencil/pen still and using it to draw on a rotating canvas underneath. I have a test example created in the p5.js editor.
The example draws two dots, one red and one blue. The goal is to create a mark, or trail, using the blue dot on the rotating graphics object below.
function setup() {
createCanvas(400, 400);
background(255);
img = createGraphics(200, 200);
img.background(150);
img.strokeWeight(3);
//rectMode(CENTER);
}
function draw() {
background('lightYellow');
translate(100, 100);
img.background('lightBlue');
img.push();
img.translate(100, 100);
img.rotate(radians(frameCount));
img.fill(240);
img.noStroke();
img.rect(-50, -50, 100, 100);
img.strokeWeight(4);
img.stroke('red');
img.point(20, 20);
img.pop();
img.stroke('blue');
img.strokeWeight(4);
img.point(100, 80);
image(img, 0, 0);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.min.js"></script>
Is there a way to do this with my current example or should I try something different?