Add fishing plugin (#108)
This commit is contained in:
@@ -26,6 +26,7 @@ package net.runelite.api;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Polygon;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Objects;
|
||||
import net.runelite.rs.api.CombatInfo1;
|
||||
import net.runelite.rs.api.CombatInfo2;
|
||||
@@ -185,6 +186,11 @@ public abstract class Actor extends Renderable
|
||||
return Perspective.getCanvasTextLocation(client, graphics, getLocalLocation(), text, zOffset);
|
||||
}
|
||||
|
||||
public Point getCanvasImageLocation(Graphics2D graphics, BufferedImage image, int zOffset)
|
||||
{
|
||||
return Perspective.getCanvasImageLocation(client, graphics, getLocalLocation(), image, zOffset);
|
||||
}
|
||||
|
||||
public Point getMinimapLocation()
|
||||
{
|
||||
return Perspective.worldToMiniMap(client, getX(), getY());
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Polygon;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class Perspective
|
||||
{
|
||||
@@ -281,4 +282,32 @@ public class Perspective
|
||||
return new Point(xOffset, p.getY());
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates image position and centers depending on image size.
|
||||
*
|
||||
* @param client
|
||||
* @param graphics
|
||||
* @param localLocation local location of the tile
|
||||
* @param image image for size measurement
|
||||
* @param zOffset offset from ground plane
|
||||
* @return a {@link Point} on screen corresponding to the given
|
||||
* localLocation.
|
||||
*/
|
||||
public static Point getCanvasImageLocation(Client client, Graphics2D graphics, Point localLocation, BufferedImage image, 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() - image.getWidth() / 2;
|
||||
int yOffset = p.getY() - image.getHeight() / 2;
|
||||
|
||||
return new Point(xOffset, yOffset);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user