use of net.runelite.api.coords.LocalPoint in project runelite by runelite.
the class PohOverlay method render.
@Override
public Dimension render(Graphics2D graphics) {
LocalPoint localLocation = client.getLocalPlayer().getLocalLocation();
plugin.getPohObjects().forEach((object, tile) -> {
LocalPoint location = object.getLocalLocation();
if (tile.getPlane() == client.getPlane() && localLocation.distanceTo(location) <= MAX_DISTANCE) {
PohIcons icon = PohIcons.getIcon(object.getId());
if (icon != null && iconList.contains(icon)) {
net.runelite.api.Point minimapLoc = Perspective.getMiniMapImageLocation(client, object.getLocalLocation(), icon.getImage());
if (minimapLoc != null) {
graphics.drawImage(icon.getImage(), minimapLoc.getX(), minimapLoc.getY(), null);
}
}
}
});
return null;
}
use of net.runelite.api.coords.LocalPoint in project runelite by runelite.
the class TitheFarmPlantOverlay method render.
@Override
public Dimension render(Graphics2D graphics) {
Widget viewport = client.getViewportWidget();
for (TitheFarmPlant plant : plugin.getPlants()) {
LocalPoint localLocation = LocalPoint.fromWorld(client, plant.getWorldLocation());
net.runelite.api.Point canvasLocation = Perspective.worldToCanvas(client, localLocation.getX(), localLocation.getY(), client.getPlane());
if (viewport != null && localLocation != null) {
switch(plant.getState()) {
case UNWATERED:
drawTimerOnPlant(graphics, plant, canvasLocation, config.getColorUnwatered());
break;
case WATERED:
drawTimerOnPlant(graphics, plant, canvasLocation, config.getColorWatered());
break;
case GROWN:
drawTimerOnPlant(graphics, plant, canvasLocation, config.getColorGrown());
break;
}
}
}
return null;
}
use of net.runelite.api.coords.LocalPoint in project runelite by runelite.
the class BarrowsOverlay method renderBarrowsBrothers.
private void renderBarrowsBrothers(Graphics2D graphics) {
for (BarrowsBrothers brother : BarrowsBrothers.values()) {
LocalPoint localLocation = LocalPoint.fromWorld(client, brother.getLocation());
if (localLocation == null) {
continue;
}
net.runelite.api.Point minimapText = Perspective.getCanvasTextMiniMapLocation(client, graphics, localLocation, brother.getName());
if (minimapText != null) {
graphics.setColor(Color.black);
graphics.drawString(brother.getName(), minimapText.getX() + 1, minimapText.getY() + 1);
graphics.setColor(Color.cyan);
graphics.drawString(brother.getName(), minimapText.getX(), minimapText.getY());
}
}
}
use of net.runelite.api.coords.LocalPoint in project runelite by runelite.
the class Perspective method getCanvasTextMiniMapLocation.
/**
* Calculates text position and centers on minimap depending on string length.
*
* @param client
* @param graphics
* @param localLocation local location of the tile
* @param text string for width measurement
* @return a {@link Point} on screen corresponding to the given
* localLocation.
*/
public static Point getCanvasTextMiniMapLocation(Client client, Graphics2D graphics, LocalPoint localLocation, String text) {
Point p = Perspective.worldToMiniMap(client, localLocation.getX(), localLocation.getY());
if (p == null) {
return null;
}
FontMetrics fm = graphics.getFontMetrics();
Rectangle2D bounds = fm.getStringBounds(text, graphics);
int xOffset = p.getX() - (int) (bounds.getWidth() / 2);
int yOffset = p.getY() - (int) (bounds.getHeight() / 2) + fm.getAscent();
return new Point(xOffset, yOffset);
}
use of net.runelite.api.coords.LocalPoint in project runelite by runelite.
the class Perspective method getCanvasSpriteLocation.
/**
* Calculates sprite position and centers depending on sprite size.
*
* @param client
* @param graphics
* @param localLocation local location of the tile
* @param sprite SpritePixel for size measurement
* @param zOffset offset from ground plane
* @return a {@link Point} on screen corresponding to the given
* localLocation.
*/
public static Point getCanvasSpriteLocation(Client client, Graphics2D graphics, LocalPoint localLocation, SpritePixels sprite, int zOffset) {
int plane = client.getPlane();
Point p = Perspective.worldToCanvas(client, localLocation.getX(), localLocation.getY(), plane, zOffset);
if (p == null) {
return null;
}
int xOffset = p.getX() - sprite.getWidth() / 2;
int yOffset = p.getY() - sprite.getHeight() / 2;
return new Point(xOffset, yOffset);
}
Aggregations