diff --git a/src/com/annimon/graphics/GraphicsExt.java b/src/com/annimon/graphics/GraphicsExt.java index 1ee2ef8..f4a0c19 100644 --- a/src/com/annimon/graphics/GraphicsExt.java +++ b/src/com/annimon/graphics/GraphicsExt.java @@ -91,11 +91,27 @@ public class GraphicsExt { if (clip != null) { double[] coords = clip.clip(p1[0], p1[1], p2[0], p2[1]); g.drawLine(convertX(coords[0]), convertY(coords[1]), convertX(coords[2]), convertY(coords[3])); - } else { + } else { g.drawLine(convertX(p1[0]), convertY(p1[1]), convertX(p2[0]), convertY(p2[1])); } } + public void rect(double x, double y, double width, double height) { + rect(new Rect(x, y, width, height)); + } + + public void rect(Rect rect) { + final double x1 = rect.getX(); + final double y1 = rect.getY(); + final double x2 = x1 + rect.getWidth(); + final double y2 = y1 + rect.getHeight(); + move(x1, y1); + draw(x2, y1); + draw(x2, y2); + draw(x1, y2); + draw(x1, y1); + } + private int convertX(double x) { return (int) (x * (width / X_MAX) + 0.5d); }