public static void filledSquare(double x, double y, double r) {
        if (r < 0) {
            throw new IllegalArgumentException("square side length must be nonnegative");
        }
        double xs = scaleX(x);
        double ys = scaleY(y);
        double ws = factorX(2 * r);
        double hs = factorY(2 * r);
        if (ws <= 1 && hs <= 1) {
            pixel(x, y);
        } else {
            offscreen.fill(new Rectangle2D.Double(xs - ws / 2, ys - hs / 2, ws, hs));
        }
        draw();
    }