Thank you, didn't realise it would be some thing so simple.
I've changed the design a bit and added a square for every time the mouse is idle.
I've also added the ability to save the image when you are done with the program.
Is there a way to change the dpi from 72 to 300 in the save() function?
I have tried using the PDF export function but it records every frame, slowing down the program and making it impossible to practically open in acrobat or photoshop. I have also tried the PDF export function for recording one frame but it only records the first frame.
Code:import processing.pdf.*;
PFont myFont;
Point mouse;
float d;
int pmX;
int pmY;
float l;
int h;
int m;
int s;
int time;
void setup() {
size(screen.width/2,screen.height/2 + 60);
myFont = createFont("AndaleMono", 10);
background(255);
smooth();
}
void draw() {
mouse = MouseInfo.getPointerInfo().getLocation();
if(frameCount > 1) {
d += dist(pmX*2, pmY*2, mouse.x*2, mouse.y*2);
stroke(0);
line(pmX/2, pmY/2, mouse.x/2, mouse.y/2);
}
if (mouse.x/2 == pmX/2 && mouse.y/2 == pmY/2) {
rectMode(CENTER);
noStroke();
fill(130, 200, 252);
rect(mouse.x/2, mouse.y/2, 5, 5);
}
//Info Container
fill(130, 200, 252);
rectMode(CORNER);
noStroke();
rect(0, screen.height/2, screen.width/2, 60);
fill(0);
textFont(myFont);
text("Distance (pixles) = " + d, 15, screen.height/2 + 20);
//Screen Size
text("Screen resolution (pixles) = " + screen.width + " x " + screen.height, 15, screen.height/2 + 40);
//Time running
text("Time running (milliseconds) = " + millis(), 300, screen.height/2 + 20);
//Instructions
text("Save image by pressing 's'", 300, screen.height/2 + 40);
println("pmX is " + pmX + " and PmY is " + pmY + "mX is " + mouse.x + "mY is " + mouse.y);
pmX = mouse.x;
pmY = mouse.y;
}
void keyPressed() {
if (key == 's') {
saveFrame("mouse.tif");
}
}