diff --git a/runelite-api/src/main/java/net/runelite/api/Perspective.java b/runelite-api/src/main/java/net/runelite/api/Perspective.java index a6cbe297a7..f2d6d6cd1c 100644 --- a/runelite-api/src/main/java/net/runelite/api/Perspective.java +++ b/runelite-api/src/main/java/net/runelite/api/Perspective.java @@ -404,6 +404,30 @@ public class Perspective return new Point(xOffset, yOffset); } + /** + * Calculates image position and centers depending on image size. + * + * @param client + * @param localLocation local location of the tile + * @param image image for size measurement + * @return a {@link Point} on screen corresponding to the given + * localLocation. + */ + public static Point getMiniMapImageLocation(Client client, Point localLocation, BufferedImage image) + { + Point p = Perspective.worldToMiniMap(client, localLocation.getX(), localLocation.getY()); + + if (p == null) + { + return null; + } + + int xOffset = p.getX() - image.getWidth() / 2; + int yOffset = p.getY() - image.getHeight() / 2; + + return new Point(xOffset, yOffset); + } + /** * Calculates sprite position and centers depending on sprite size. *