Search in sources :

Example 6 with Point

use of net.runelite.api.Point in project runelite by runelite.

the class OverlayUtil method renderActorOverlay.

public static void renderActorOverlay(Graphics2D graphics, Actor actor, String text, Color color) {
    Polygon poly = actor.getCanvasTilePoly();
    if (poly != null) {
        renderPolygon(graphics, poly, color);
    }
    Point textLocation = actor.getCanvasTextLocation(graphics, text, actor.getLogicalHeight() + 40);
    if (textLocation != null) {
        renderTextLocation(graphics, textLocation, text, color);
    }
}
Also used : LocalPoint(net.runelite.api.coords.LocalPoint) Point(net.runelite.api.Point) Polygon(java.awt.Polygon)

Example 7 with Point

use of net.runelite.api.Point in project runelite by runelite.

the class OverlayUtil method renderTileOverlay.

public static void renderTileOverlay(Graphics2D graphics, TileObject tileObject, String text, Color color) {
    Polygon poly = tileObject.getCanvasTilePoly();
    if (poly != null) {
        renderPolygon(graphics, poly, color);
    }
    Point minimapLocation = tileObject.getMinimapLocation();
    if (minimapLocation != null) {
        renderMinimapLocation(graphics, minimapLocation, color);
    }
    Point textLocation = tileObject.getCanvasTextLocation(graphics, text, 0);
    if (textLocation != null) {
        renderTextLocation(graphics, textLocation, text, color);
    }
}
Also used : LocalPoint(net.runelite.api.coords.LocalPoint) Point(net.runelite.api.Point) Polygon(java.awt.Polygon)

Example 8 with Point

use of net.runelite.api.Point in project runelite by runelite.

the class XpGlobesOverlay method drawTooltipIfMouseover.

private void drawTooltipIfMouseover(Graphics2D graphics, XpGlobe mouseOverSkill, Ellipse2D drawnGlobe) {
    Point mouse = client.getMouseCanvasPosition();
    int mouseX = mouse.getX();
    int mouseY = mouse.getY();
    if (!drawnGlobe.contains(mouseX, mouseY)) {
        return;
    }
    // draw tooltip under the globe of the mouse location
    int x = (int) drawnGlobe.getX() - (TOOLTIP_RECT_SIZE_X / 2) + (config.xpOrbSize() / 2);
    int y = (int) drawnGlobe.getY() + config.xpOrbSize() + 10;
    String skillName = mouseOverSkill.getSkillName();
    String skillLevel = Integer.toString(mouseOverSkill.getCurrentLevel());
    DecimalFormat decimalFormat = new DecimalFormat("###,###,###");
    String skillCurrentXp = decimalFormat.format(mouseOverSkill.getCurrentXp());
    PanelComponent xpTooltip = new PanelComponent();
    xpTooltip.setPosition(new java.awt.Point(x, y));
    xpTooltip.setWidth(TOOLTIP_RECT_SIZE_X);
    List<PanelComponent.Line> lines = xpTooltip.getLines();
    lines.add(new PanelComponent.Line(skillName, Color.WHITE, skillLevel, Color.WHITE));
    lines.add(new PanelComponent.Line("Current xp:", Color.ORANGE, skillCurrentXp, Color.WHITE));
    if (mouseOverSkill.getGoalXp() != -1) {
        String skillXpToLvl = decimalFormat.format(mouseOverSkill.getGoalXp() - mouseOverSkill.getCurrentXp());
        lines.add(new PanelComponent.Line("Xp to level:", Color.ORANGE, skillXpToLvl, Color.WHITE));
        // Create progress bar for skill.
        ProgressBarComponent progressBar = new ProgressBarComponent();
        double progress = mouseOverSkill.getSkillProgress(Experience.getXpForLevel(mouseOverSkill.getCurrentLevel()), mouseOverSkill.getCurrentXp(), mouseOverSkill.getGoalXp());
        progressBar.setProgress(progress);
        xpTooltip.setProgressBar(progressBar);
    }
    xpTooltip.render(graphics);
}
Also used : DecimalFormat(java.text.DecimalFormat) PanelComponent(net.runelite.client.ui.overlay.components.PanelComponent) Point(net.runelite.api.Point) Point(net.runelite.api.Point) ProgressBarComponent(net.runelite.client.ui.overlay.components.ProgressBarComponent)

Example 9 with Point

use of net.runelite.api.Point in project runelite by runelite.

the class AgilityOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    LocalPoint playerLocation = client.getLocalPlayer().getLocalLocation();
    Point mousePosition = client.getMouseCanvasPosition();
    plugin.getObstacles().forEach((object, tile) -> {
        if (tile.getPlane() == client.getPlane() && object.getLocalLocation().distanceTo(playerLocation) < MAX_DISTANCE) {
            Area objectClickbox = object.getClickbox();
            if (objectClickbox != null) {
                Color configColor = config.getOverlayColor();
                if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY())) {
                    graphics.setColor(configColor.darker());
                } else {
                    graphics.setColor(configColor);
                }
                graphics.draw(objectClickbox);
                graphics.setColor(new Color(configColor.getRed(), configColor.getGreen(), configColor.getBlue(), 50));
                graphics.fill(objectClickbox);
            }
        }
    });
    return null;
}
Also used : Area(java.awt.geom.Area) LocalPoint(net.runelite.api.coords.LocalPoint) Color(java.awt.Color) LocalPoint(net.runelite.api.coords.LocalPoint) Point(net.runelite.api.Point)

Example 10 with Point

use of net.runelite.api.Point in project runelite by runelite.

the class JarvisTest method test2.

@Test
public void test2() {
    Point[] points = { new Point(0, 3), new Point(4, 2), new Point(3, 5), new Point(5, 3), new Point(3, 0), new Point(1, 1), new Point(1, 2), new Point(2, 2) };
    List<Point> result = Jarvis.convexHull(Arrays.asList(points));
    Assert.assertEquals(5, result.size());
    Assert.assertEquals(new Point(0, 3), result.get(0));
    Assert.assertEquals(new Point(3, 5), result.get(1));
    Assert.assertEquals(new Point(5, 3), result.get(2));
    Assert.assertEquals(new Point(3, 0), result.get(3));
    Assert.assertEquals(new Point(1, 1), result.get(4));
}
Also used : Point(net.runelite.api.Point) Test(org.junit.Test)

Aggregations

Point (net.runelite.api.Point)28 LocalPoint (net.runelite.api.coords.LocalPoint)12 Polygon (java.awt.Polygon)9 Color (java.awt.Color)6 BufferedImage (java.awt.image.BufferedImage)5 Inject (net.runelite.api.mixins.Inject)4 FontMetrics (java.awt.FontMetrics)3 Rectangle (java.awt.Rectangle)3 Area (java.awt.geom.Area)3 ArrayList (java.util.ArrayList)3 WorldPoint (net.runelite.api.coords.WorldPoint)3 WidgetItem (net.runelite.api.widgets.WidgetItem)3 ImageIO (javax.imageio.ImageIO)2 Player (net.runelite.api.Player)2 Vertex (net.runelite.api.model.Vertex)2 Test (org.junit.Test)2 Inject (com.google.inject.Inject)1 Dimension (java.awt.Dimension)1 Graphics (java.awt.Graphics)1 Graphics2D (java.awt.Graphics2D)1