Skip to content

Commit

Permalink
runelite-client: extend overlay util to render Areas and LocalPoint
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderhenne committed Mar 26, 2018
1 parent 04abc1f commit 0aae96f
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.awt.RenderingHints;
import java.awt.geom.Area;
import java.awt.image.BufferedImage;
import net.runelite.api.Actor;
import net.runelite.api.Client;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
import net.runelite.api.TileObject;
import net.runelite.api.coords.LocalPoint;
import net.runelite.client.ui.FontManager;


Expand Down Expand Up @@ -72,6 +76,15 @@ public static void renderTextLocation(Graphics2D graphics, Point txtLoc, String
graphics.drawString(text, x, y);
}

public static void renderImageLocation(Client client, Graphics2D graphics, LocalPoint localPoint, BufferedImage image, int zOffset)
{
net.runelite.api.Point imageLocation = Perspective.getCanvasImageLocation(client, graphics, localPoint, image, zOffset);
if (imageLocation != null)
{
renderImageLocation(graphics, imageLocation, image);
}
}

public static void renderImageLocation(Graphics2D graphics, Point imgLoc, BufferedImage image)
{
int x = imgLoc.getX();
Expand Down Expand Up @@ -131,6 +144,36 @@ public static void renderTileOverlay(Graphics2D graphics, TileObject tileObject,
}
}

public static void renderTileOverlay(Client client, Graphics2D graphics, LocalPoint localLocation, BufferedImage image, Color color)
{
Polygon poly = Perspective.getCanvasTilePoly(client, localLocation);
if (poly != null)
{
renderPolygon(graphics, poly, color);
}

renderImageLocation(client, graphics, localLocation, image, 0);
}

public static void renderHoverableArea(Graphics2D graphics, Area area, net.runelite.api.Point mousePosition, Color fillColor, Color borderColor, Color borderHoverColor)
{
if (area != null)
{
if (area.contains(mousePosition.getX(), mousePosition.getY()))
{
graphics.setColor(borderHoverColor);
}
else
{
graphics.setColor(borderColor);
}

graphics.draw(area);
graphics.setColor(fillColor);
graphics.fill(area);
}
}

public static void setGraphicProperties(Graphics2D graphics)
{
graphics.setFont(FontManager.getRunescapeFont());
Expand Down

0 comments on commit 0aae96f

Please sign in to comment.