net.runelite.api.Point Java Examples
The following examples show how to use
net.runelite.api.Point.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OverlayUtil.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
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); } }
Example #2
Source File: StealingArtefactsWorldMapPoint.java From plugins with GNU General Public License v3.0 | 6 votes |
StealingArtefactsWorldMapPoint(WorldPoint worldPoint, BufferedImage bufferedImage) { super(worldPoint, null); hairClipImage = bufferedImage; BufferedImage mapArrowImage = getCachedMapArrowImage(); artefactWorldMapImage = new BufferedImage(mapArrowImage.getWidth(), mapArrowImage.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics graphics = artefactWorldMapImage.getGraphics(); graphics.drawImage(mapArrowImage, 0, 0, null); graphics.drawImage(hairClipImage, 0, 0, null); artefactWorldMapPoint = new Point(artefactWorldMapImage.getWidth() / 2, artefactWorldMapImage.getHeight()); this.setSnapToEdge(true); this.setJumpOnClick(true); this.setImage(artefactWorldMapImage); this.setImagePoint(artefactWorldMapPoint); }
Example #3
Source File: AbyssOverlay.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private void renderRift(Graphics2D graphics, DecorativeObject object) { AbyssRifts rift = AbyssRifts.getRift(object.getId()); if (rift == null || !plugin.getRifts().contains(rift)) { return; } Point mousePosition = client.getMouseCanvasPosition(); Shape objectClickbox = object.getClickbox(); if (objectClickbox != null) { if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY())) { graphics.setColor(Color.MAGENTA.darker()); } else { graphics.setColor(Color.MAGENTA); } graphics.draw(objectClickbox); graphics.setColor(new Color(255, 0, 255, 20)); graphics.fill(objectClickbox); } }
Example #4
Source File: AboveSceneOverlay.java From plugins with GNU General Public License v3.0 | 6 votes |
private void renderHealthBars(Graphics2D graphics) { for (Map.Entry<WidgetInfo, Point> teammate : TEAMMATES.entrySet()) { Widget widget = client.getWidget(teammate.getKey()); if (widget == null) { continue; } // This will give us two elements, the first will be current health, and the second will be max health String[] teammateHealth = widget.getText().split(" / "); graphics.setColor(HEALTH_BAR_COLOR); graphics.fillRect((widget.getCanvasLocation().getX() - teammate.getValue().getX()), (widget.getCanvasLocation().getY() - teammate.getValue().getY()), getBarWidth(Integer.parseInt(teammateHealth[1]), Integer.parseInt(teammateHealth[0])), HEALTH_BAR_HEIGHT); } }
Example #5
Source File: AboveWidgetsOverlay.java From plugins with GNU General Public License v3.0 | 6 votes |
private void renderInventoryHighlights(Graphics2D graphics, int itemID, Color color) { Widget inventory = client.getWidget(WidgetInfo.INVENTORY); if (inventory == null || inventory.isHidden() || itemID == -1) { return; } Color highlight = new Color(color.getRed(), color.getGreen(), color.getBlue(), 150); BufferedImage image = ImageUtil.fillImage(client.createItemSprite(itemID, 300, 2, 0, 0, true, 710).toBufferedImage(), highlight); for (WidgetItem item : inventory.getWidgetItems()) { if (item.getId() == itemID) { OverlayUtil.renderImageLocation(graphics, item.getCanvasLocation(), image); //The item's text quantity is rendered after the sprite's image is rendered so that the text appears on top if (item.getQuantity() > 1) { OverlayUtil.renderTextLocation(graphics, new Point(item.getCanvasLocation().getX() + OFFSET_X_TEXT_QUANTITY, item.getCanvasLocation().getY() + OFFSET_Y_TEXT_QUANTITY), String.valueOf(item.getQuantity()), Color.YELLOW); } } } }
Example #6
Source File: AboveSceneOverlay.java From plugins with GNU General Public License v3.0 | 6 votes |
private void drawCircle(Graphics2D graphics, LocalPoint point) { if (point == null) { return; } Point canvasPoint = Perspective.localToCanvas(client, point, 0); if (canvasPoint == null) { return; } //TODO rendering a model would be better / more accurate graphics.fillOval(canvasPoint.getX() - CENTER_OFFSET, canvasPoint.getY() - CENTER_OFFSET, EGG_DIAMETER, EGG_DIAMETER); }
Example #7
Source File: TargetWeaknessOverlay.java From plugins with GNU General Public License v3.0 | 6 votes |
private void renderTargetItem(Graphics2D graphics, NPC actor, BufferedImage image) { final LocalPoint actorPosition = actor.getLocalLocation(); final int offset = actor.getLogicalHeight() + 40; if (actorPosition == null || image == null) { return; } final Point imageLoc = Perspective.getCanvasImageLocation(client, actorPosition, image, offset); if (imageLoc != null) { OverlayUtil.renderImageLocation(graphics, imageLoc, image); } }
Example #8
Source File: DriftNetOverlay.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private void renderNets(Graphics2D graphics) { for (DriftNet net : plugin.getNETS()) { final Shape polygon = net.getNet().getConvexHull(); if (polygon != null) { OverlayUtil.renderPolygon(graphics, polygon, net.getStatus().getColor()); } String text = net.getFormattedCountText(); Point textLocation = net.getNet().getCanvasTextLocation(graphics, text, 0); if (textLocation != null) { OverlayUtil.renderTextLocation(graphics, textLocation, text, config.countColor()); } } }
Example #9
Source File: CameraOverlay.java From plugins with GNU General Public License v3.0 | 6 votes |
@Override public Dimension render(final Graphics2D graphics) { final Widget slider = client.getWidget(WidgetInfo.OPTIONS_CAMERA_ZOOM_SLIDER_HANDLE); final Point mousePos = client.getMouseCanvasPosition(); if (slider == null || slider.isHidden() || !slider.getBounds().contains(mousePos.getX(), mousePos.getY())) { return null; } final int value = client.getVar(VarClientInt.CAMERA_ZOOM_RESIZABLE_VIEWPORT); final int max = config.innerLimit() ? config.INNER_ZOOM_LIMIT : CameraPlugin.DEFAULT_INNER_ZOOM_LIMIT; tooltipManager.add(new Tooltip("Camera Zoom: " + value + " / " + max)); return null; }
Example #10
Source File: TargetWeaknessOverlay.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private void renderTargetItem(Graphics2D graphics, NPC actor, BufferedImage image) { final LocalPoint actorPosition = actor.getLocalLocation(); final int offset = actor.getLogicalHeight() + 40; if (actorPosition == null || image == null) { return; } final Point imageLoc = Perspective.getCanvasImageLocation(client, actorPosition, image, offset); if (imageLoc != null) { OverlayUtil.renderImageLocation(graphics, imageLoc, image); } }
Example #11
Source File: GroundMarkerMinimapOverlay.java From plugins with GNU General Public License v3.0 | 6 votes |
private void drawOnMinimap(Graphics2D graphics, WorldPoint point, Color color) { LocalPoint lp = LocalPoint.fromWorld(client, point); if (lp == null) { return; } Point posOnMinimap = Perspective.localToMinimap(client, lp); if (posOnMinimap == null) { return; } OverlayUtil.renderMinimapRect(client, graphics, posOnMinimap, TILE_WIDTH, TILE_HEIGHT, color); }
Example #12
Source File: RepairOverlay.java From plugins with GNU General Public License v3.0 | 6 votes |
private void renderObjectOverlay(Graphics2D graphics, Shape area, Color color, Point mousePosition) { if (area == null) { return; } graphics.setColor(color); graphics.setStroke(new BasicStroke(2)); graphics.draw(area); graphics.setColor(setColorAlpha(color, 50)); graphics.fill(area); if (area.contains(mousePosition.getX(), mousePosition.getY())) { graphics.setColor(setColorAlpha(color, 60)); graphics.fill(area); } }
Example #13
Source File: XpDropOverlay.java From plugins with GNU General Public License v3.0 | 6 votes |
@Override public Dimension render(Graphics2D graphics) { if (plugin.getTickShow() > 0) { final Actor opponent = plugin.getLastOpponent(); if (opponent != null) { int offset = opponent.getLogicalHeight() + 50; String damageStr = String.valueOf(plugin.getDamage()); Point textLocation = opponent.getCanvasTextLocation(graphics, damageStr, offset); if (textLocation != null && plugin.getDamage() != 0) { OverlayUtil.renderTextLocation(graphics, textLocation, damageStr, config.getDamageColor()); } } } return null; }
Example #14
Source File: Jarvis.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
/** * Computes and returns the convex hull of the passed points. * <p> * The size of the list must be at least 3, otherwise this method will * return null. * * @param points list of points * @return list containing the points part of the convex hull */ @Deprecated public static List<Point> convexHull(List<Point> points) { int[] xs = new int[points.size()]; int[] ys = new int[xs.length]; for (int i = 0; i < xs.length; i++) { Point p = points.get(i); xs[i] = p.getX(); ys[i] = p.getY(); } SimplePolygon poly = convexHull(xs, ys); if (poly == null) { return null; } return poly.toRuneLitePointList(); }
Example #15
Source File: ExtUtils.java From ExternalPlugins with GNU General Public License v3.0 | 6 votes |
public void click(Point p) { assert !client.isClientThread(); if (client.isStretchedEnabled()) { final Dimension stretched = client.getStretchedDimensions(); final Dimension real = client.getRealDimensions(); final double width = (stretched.width / real.getWidth()); final double height = (stretched.height / real.getHeight()); final Point point = new Point((int) (p.getX() * width), (int) (p.getY() * height)); mouseEvent(501, point); mouseEvent(502, point); mouseEvent(500, point); return; } mouseEvent(501, p); mouseEvent(502, p); mouseEvent(500, p); }
Example #16
Source File: PoisonActorOverlay.java From plugins with GNU General Public License v3.0 | 6 votes |
private void renderOverlayFor(Graphics2D g, Actor actor, int damage, String timeLeft, boolean venomed) { BufferedImage splat = plugin.getSplat(venomed ? SpriteID.HITSPLAT_DARK_GREEN_VENOM : SpriteID.HITSPLAT_GREEN_POISON, damage); LocalPoint localLocation = actor.getLocalLocation(); if (localLocation == null) { return; } Point overlayLocation = Perspective.getCanvasImageLocation(client, localLocation, splat, 0); if (overlayLocation == null) { return; } int textOffset = splat.getHeight() - (splat.getHeight() - fontSize) / 2; Point textLocation = new Point(overlayLocation.getX() + splat.getWidth() + 3, overlayLocation.getY() + textOffset); g.drawImage(splat, overlayLocation.getX(), overlayLocation.getY(), null); OverlayUtil.renderTextLocation(g, textLocation, timeLeft, Color.WHITE); }
Example #17
Source File: RaidsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private Point findLobbyBase() { Tile[][] tiles = client.getScene().getTiles()[LOBBY_PLANE]; for (int x = 0; x < SCENE_SIZE; x++) { for (int y = 0; y < SCENE_SIZE; y++) { if (tiles[x][y] == null || tiles[x][y].getWallObject() == null) { continue; } if (tiles[x][y].getWallObject().getId() == NullObjectID.NULL_12231) { return tiles[x][y].getSceneLocation(); } } } return null; }
Example #18
Source File: ImplingsOverlay.java From plugins with GNU General Public License v3.0 | 6 votes |
private void drawSpawn(Graphics2D graphics, WorldPoint point, String text, Color color) { //Don't draw spawns if Player is not in range if (point.distanceTo(client.getLocalPlayer().getWorldLocation()) >= 32) { return; } LocalPoint localPoint = LocalPoint.fromWorld(client, point); if (localPoint == null) { return; } Polygon poly = Perspective.getCanvasTilePoly(client, localPoint); if (poly != null) { OverlayUtil.renderPolygon(graphics, poly, color); } Point textPoint = Perspective.getCanvasTextLocation(client, graphics, localPoint, text, 0); if (textPoint != null) { OverlayUtil.renderTextLocation(graphics, textPoint, text, color); } }
Example #19
Source File: DevToolsOverlay.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private void renderProjectiles(Graphics2D graphics) { List<Projectile> projectiles = client.getProjectiles(); for (Projectile projectile : projectiles) { int projectileId = projectile.getId(); String text = "(ID: " + projectileId + ")"; int x = (int) projectile.getX(); int y = (int) projectile.getY(); LocalPoint projectilePoint = new LocalPoint(x, y); Point textLocation = Perspective.getCanvasTextLocation(client, graphics, projectilePoint, text, 0); if (textLocation != null) { OverlayUtil.renderTextLocation(graphics, textLocation, text, Color.RED); } } }
Example #20
Source File: NpcMinimapOverlay.java From plugins with GNU General Public License v3.0 | 6 votes |
private void renderNpcOverlay(Graphics2D graphics, NPC actor, String name, Color color) { NPCDefinition npcDefinition = actor.getTransformedDefinition(); if (npcDefinition == null || !npcDefinition.isInteractible() || (actor.isDead() && config.ignoreDeadNpcs())) { return; } final Point minimapLocation = actor.getMinimapLocation(); if (minimapLocation != null) { OverlayUtil.renderMinimapLocation(graphics, minimapLocation, color.darker()); if (config.drawMinimapNames()) { OverlayUtil.renderTextLocation(graphics, minimapLocation, name, color); } } }
Example #21
Source File: AbyssOverlay.java From plugins with GNU General Public License v3.0 | 6 votes |
private void renderRift(Graphics2D graphics, DecorativeObject object) { AbyssRifts rift = AbyssRifts.getRift(object.getId()); if (rift == null || !plugin.getRifts().contains(rift)) { return; } Point mousePosition = client.getMouseCanvasPosition(); Shape objectClickbox = object.getClickbox(); if (objectClickbox != null) { if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY())) { graphics.setColor(Color.MAGENTA.darker()); } else { graphics.setColor(Color.MAGENTA); } graphics.draw(objectClickbox); graphics.setColor(new Color(255, 0, 255, 20)); graphics.fill(objectClickbox); } }
Example #22
Source File: XpGlobesOverlay.java From plugins with GNU General Public License v3.0 | 6 votes |
private void drawProgressLabel(Graphics2D graphics, XpGlobe globe, int startXp, int goalXp, int x, int y) { if (goalXp <= globe.getCurrentXp()) { return; } // Convert to int just to limit the decimal cases String progress = (int) (getSkillProgress(startXp, globe.getCurrentXp(), goalXp)) + "%"; final FontMetrics metrics = graphics.getFontMetrics(); int drawX = x + (config.xpOrbSize() / 2) - (metrics.stringWidth(progress) / 2); int drawY = y + (config.xpOrbSize() / 2) + (metrics.getHeight() / 2) - metrics.getMaxDescent(); OverlayUtil.renderTextLocation(graphics, new Point(drawX, drawY), progress, Color.WHITE); }
Example #23
Source File: DriftNetOverlay.java From plugins with GNU General Public License v3.0 | 6 votes |
private void renderNets(Graphics2D graphics) { for (DriftNet net : plugin.getNETS()) { final Shape polygon = net.getNet().getConvexHull(); if (polygon != null) { OverlayUtil.renderPolygon(graphics, polygon, net.getStatus().getColor()); } String text = net.getFormattedCountText(); Point textLocation = net.getNet().getCanvasTextLocation(graphics, text, 0); if (textLocation != null) { OverlayUtil.renderTextLocation(graphics, textLocation, text, config.countColor()); } } }
Example #24
Source File: JarvisTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void test() { Point[] points = { new Point(0, 3), new Point(1, 1), new Point(2, 2), new Point(4, 4), new Point(0, 0), new Point(1, 2), new Point(3, 1), new Point(3, 3) }; List<Point> result = Jarvis.convexHull(Arrays.asList(points)); Assert.assertEquals(4, result.size()); Assert.assertEquals(new Point(0, 0), result.get(0)); Assert.assertEquals(new Point(0, 3), result.get(1)); Assert.assertEquals(new Point(4, 4), result.get(2)); Assert.assertEquals(new Point(3, 1), result.get(3)); }
Example #25
Source File: MiningCoalBagOverlay.java From plugins with GNU General Public License v3.0 | 5 votes |
@Override public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget) { if (!config.showCoalBagOverlay() || (itemId != ItemID.COAL_BAG && itemId != ItemID.COAL_BAG_12019)) { return; } graphics.setFont(FontManager.getRunescapeSmallFont()); graphics.setColor(Color.WHITE); Point location = itemWidget.getCanvasLocation(); graphics.drawString(config.amountOfCoalInCoalBag() + "", location.getX(), location.getY() + 14); }
Example #26
Source File: ImplingsOverlay.java From plugins with GNU General Public License v3.0 | 5 votes |
private void drawImp(Graphics2D graphics, Actor actor, String text, Color color) { Polygon poly = actor.getCanvasTilePoly(); if (poly != null) { OverlayUtil.renderPolygon(graphics, poly, color); } Point textLocation = actor.getCanvasTextLocation(graphics, text, actor.getLogicalHeight()); if (textLocation != null) { OverlayUtil.renderTextLocation(graphics, textLocation, text, color); } }
Example #27
Source File: TargetMinimapOverlay.java From plugins with GNU General Public License v3.0 | 5 votes |
private void renderTargetOverlay(Graphics2D graphics, NPC actor, String name, Color color) { Point minimapLocation = actor.getMinimapLocation(); if (minimapLocation != null) { OverlayUtil.renderMinimapLocation(graphics, minimapLocation, color); if (config.drawMinimapNames()) { OverlayUtil.renderTextLocation(graphics, minimapLocation, name, color); } } }
Example #28
Source File: TearsOfGuthixOverlay.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Override public Dimension render(Graphics2D graphics) { plugin.getStreams().forEach((object, timer) -> { final Point position = object.getCanvasLocation(100); if (position == null) { return; } final ProgressPieComponent progressPie = new ProgressPieComponent(); progressPie.setDiameter(15); progressPie.setFill(CYAN_ALPHA); progressPie.setBorderColor(Color.CYAN); progressPie.setPosition(position); final Duration duration = Duration.between(timer, Instant.now()); progressPie.setProgress(1 - (duration.compareTo(MAX_TIME) < 0 ? (double) duration.toMillis() / MAX_TIME.toMillis() : 1)); progressPie.render(graphics); }); return null; }
Example #29
Source File: WoodcuttingPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onGameObjectDespawned(final GameObjectDespawned event) { final GameObject object = event.getGameObject(); Tree tree = Tree.findTree(object.getId()); if (tree != null) { if (tree.getRespawnTime() != null && !recentlyLoggedIn && currentPlane == object.getPlane()) { Point max = object.getSceneMaxLocation(); Point min = object.getSceneMinLocation(); int lenX = max.getX() - min.getX(); int lenY = max.getY() - min.getY(); log.debug("Adding respawn timer for {} tree at {}", tree, object.getLocalLocation()); final int region = client.getLocalPlayer().getWorldLocation().getRegionID(); TreeRespawn treeRespawn = new TreeRespawn(tree, lenX, lenY, WorldPoint.fromScene(client, min.getX(), min.getY(), client.getPlane()), Instant.now(), (int) tree.getRespawnTime(region).toMillis()); respawns.add(treeRespawn); } if (tree == Tree.REDWOOD) { treeObjects.remove(event.getGameObject()); } } }
Example #30
Source File: FpsOverlay.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Override public Dimension render(Graphics2D graphics) { if (!config.drawFps()) { return null; } // On resizable bottom line mode the logout button is at the top right, so offset the overlay // to account for it Widget logoutButton = client.getWidget(WidgetInfo.RESIZABLE_MINIMAP_LOGOUT_BUTTON); int xOffset = X_OFFSET; if (logoutButton != null && !logoutButton.isHidden()) { xOffset += logoutButton.getWidth(); } final String text = client.getFPS() + FPS_STRING; final int textWidth = graphics.getFontMetrics().stringWidth(text); final int textHeight = graphics.getFontMetrics().getAscent() - graphics.getFontMetrics().getDescent(); final int width = (int) client.getRealDimensions().getWidth(); final Point point = new Point(width - textWidth - xOffset, textHeight + Y_OFFSET); OverlayUtil.renderTextLocation(graphics, point, text, getFpsValueColor()); return null; }