Add fishing plugin (#108)

This commit is contained in:
Seth
2017-07-09 10:03:12 -05:00
committed by Adam
parent c351107a3a
commit 2aba47d1c3
18 changed files with 862 additions and 0 deletions

View File

@@ -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());

View File

@@ -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);
}
}