I am a complete beginner with Processing, and trying to get a row of ellipses to follow the path of the mouse with their edges touching, but not overlapping.
My first exercise was to track the mouse history in an array using a line, the commented out line adds an ellipse at each index as well:
ArrayList <PVector> history;
float preX;
float preY;
void setup() {
size(1024, 1024);
history = new ArrayList <PVector> ();
}
void draw() {
background(255);
for(int i=1; i<history.size(); i++){
//ellipse(history.get(i).x, history.get(i).y, 50,50);
PVector pointA = history.get(i-1);
PVector pointB = history.get(i);
line(pointA.x, pointA.y, pointB.x, pointB.y);
}
}
void mouseDragged() {
preX= mouseX;
preY= mouseY;
history.add(new PVector(mouseX,mouseY));
}
I think I should define a radius variable and use dist() to calculate the distance between current mouse position and the last ellipse that was drawn along the mouse history, then use an if statement to only draw the ellipse if that distance == radius*2, but get very stuck when I try to translate that into Processing code. Can anyone help get me started? I'm having a lot of trouble finding tips elsewhere - Even just a push in the right direction would be much appreciated!