Why use int(4.0f) when (int) 4.0f is likely better?
The Processing method dist(float x1, float y1, float x2, float y2) is very inefficient (no clue why).
Use this instead:
double fastDist(double x1, double y1, double x2, double y2) {
return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}