static int rectMiddleX(Rect r) { ret r == null ? 0 : r.x+r.w/2; }