made some progress, should be easier to read now
final int DIA = 50;
float circleX = 150;
float circleY = 200;
float lineX, lineY;
int RED = 0;
void setup() {
size(300, 400);
background(80, 255, 80);
fill(255, 0, 0);
ellipse(150, 200, DIA, DIA); // DIA is constant
strokeWeight(1);
}
void draw() {
if (mousePressed == true) // pressing mouse resets colour to black
RED = 0;
RED = RED + 10;
strokeWeight(2);
line(circleX, circleY, lineX, lineY);
strokeWeight(1);
fill(RED, 0, 0); // (0, 0, 0) approaches (255, 0, 0)
ellipse(circleX, circleY, DIA, DIA);
}
void mousePressed() {
circleX = (circleX + mouseX) /2; // midpoint of circleX and mouseX
circleY = (circleY + mouseY) /2; // midpoint of circleY and mouseY
}
i need to draw a line from circleX/Y to the previous circleX/Y
but i have no idea what i need to do in order to find the coordinates of the previous circle
i need to draw the line before the circle so the final circle appear on top of the line